better error handling while establishing connection
This commit is contained in:
parent
0ec8ab69a0
commit
3a00837107
6
app.js
6
app.js
|
@ -17,8 +17,6 @@ import URLProcessor from "./modules/config/URLProcessor";
|
||||||
import RoomnameGenerator from './modules/util/RoomnameGenerator';
|
import RoomnameGenerator from './modules/util/RoomnameGenerator';
|
||||||
import CQEvents from './service/connectionquality/CQEvents';
|
import CQEvents from './service/connectionquality/CQEvents';
|
||||||
import UIEvents from './service/UI/UIEvents';
|
import UIEvents from './service/UI/UIEvents';
|
||||||
import LoginDialog from './modules/UI/authentication/LoginDialog';
|
|
||||||
import UIUtil from './modules/UI/util/UIUtil';
|
|
||||||
|
|
||||||
import {openConnection} from './modules/connection';
|
import {openConnection} from './modules/connection';
|
||||||
import AuthHandler from './modules/AuthHandler';
|
import AuthHandler from './modules/AuthHandler';
|
||||||
|
@ -149,6 +147,8 @@ function initConference(localTracks, connection) {
|
||||||
room.addTrack(track);
|
room.addTrack(track);
|
||||||
APP.UI.addLocalStream(track);
|
APP.UI.addLocalStream(track);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
APP.UI.updateAuthInfo(room.isAuthEnabled(), room.getAuthLogin());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -534,6 +534,8 @@ function init() {
|
||||||
APP.statistics.start();
|
APP.statistics.start();
|
||||||
APP.connectionquality.init();
|
APP.connectionquality.init();
|
||||||
APP.keyboardshortcut.init();
|
APP.keyboardshortcut.init();
|
||||||
|
}).catch(function (err) {
|
||||||
|
console.error(err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ function JitsiConference(options) {
|
||||||
this.connection = this.options.connection;
|
this.connection = this.options.connection;
|
||||||
this.xmpp = this.connection.xmpp;
|
this.xmpp = this.connection.xmpp;
|
||||||
this.eventEmitter = new EventEmitter();
|
this.eventEmitter = new EventEmitter();
|
||||||
this.room = this.xmpp.createRoom(this.options.name, null, null, this.options.config);
|
this.room = this.xmpp.createRoom(this.options.name, this.options.config);
|
||||||
this.room.updateDeviceAvailability(RTC.getDeviceAvailability());
|
this.room.updateDeviceAvailability(RTC.getDeviceAvailability());
|
||||||
this.rtc = new RTC(this.room, options);
|
this.rtc = new RTC(this.room, options);
|
||||||
if(!RTC.options.disableAudioLevels)
|
if(!RTC.options.disableAudioLevels)
|
||||||
|
@ -44,6 +44,8 @@ function JitsiConference(options) {
|
||||||
this.lastActiveSpeaker = null;
|
this.lastActiveSpeaker = null;
|
||||||
this.dtmfManager = null;
|
this.dtmfManager = null;
|
||||||
this.somebodySupportsDTMF = false;
|
this.somebodySupportsDTMF = false;
|
||||||
|
this.authEnabled = false;
|
||||||
|
this.authIdentity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,6 +80,27 @@ JitsiConference.prototype.getName = function () {
|
||||||
return this.options.name;
|
return this.options.name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if authentication is enabled for this conference.
|
||||||
|
*/
|
||||||
|
JitsiConference.prototype.isAuthEnabled = function () {
|
||||||
|
return this.authEnabled;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if user is logged in.
|
||||||
|
*/
|
||||||
|
JitsiConference.prototype.isLoggedIn = function () {
|
||||||
|
return !!this.authIdentity;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get authorized login.
|
||||||
|
*/
|
||||||
|
JitsiConference.prototype.getAuthLogin = function () {
|
||||||
|
return this.authIdentity;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if external authentication is enabled for this conference.
|
* Check if external authentication is enabled for this conference.
|
||||||
*/
|
*/
|
||||||
|
@ -385,6 +408,9 @@ JitsiConference.prototype.onMemberJoined = function (jid, email, nick) {
|
||||||
|
|
||||||
JitsiConference.prototype.onMemberLeft = function (jid) {
|
JitsiConference.prototype.onMemberLeft = function (jid) {
|
||||||
var id = Strophe.getResourceFromJid(jid);
|
var id = Strophe.getResourceFromJid(jid);
|
||||||
|
if (id === 'focus') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var participant = this.participants[id];
|
var participant = this.participants[id];
|
||||||
delete this.participants[id];
|
delete this.participants[id];
|
||||||
this.eventEmitter.emit(JitsiConferenceEvents.USER_LEFT, id, participant);
|
this.eventEmitter.emit(JitsiConferenceEvents.USER_LEFT, id, participant);
|
||||||
|
@ -564,7 +590,8 @@ function setupListeners(conference) {
|
||||||
});
|
});
|
||||||
|
|
||||||
conference.room.addListener(AuthenticationEvents.IDENTITY_UPDATED, function (authEnabled, authIdentity) {
|
conference.room.addListener(AuthenticationEvents.IDENTITY_UPDATED, function (authEnabled, authIdentity) {
|
||||||
console.error(authEnabled, authIdentity);
|
conference.authEnabled = authEnabled;
|
||||||
|
conference.authIdentity = authIdentity;
|
||||||
});
|
});
|
||||||
|
|
||||||
conference.room.addListener(XMPPEvents.MESSAGE_RECEIVED, function (jid, displayName, txt, myJid, ts) {
|
conference.room.addListener(XMPPEvents.MESSAGE_RECEIVED, function (jid, displayName, txt, myJid, ts) {
|
||||||
|
@ -11522,12 +11549,12 @@ XMPP.prototype.connect = function (jid, password) {
|
||||||
return this._connect(jid, password);
|
return this._connect(jid, password);
|
||||||
};
|
};
|
||||||
|
|
||||||
XMPP.prototype.createRoom = function (roomName, options, useNicks, nick) {
|
XMPP.prototype.createRoom = function (roomName, options) {
|
||||||
var roomjid = roomName + '@' + this.options.hosts.muc;
|
var roomjid = roomName + '@' + this.options.hosts.muc;
|
||||||
|
|
||||||
if (useNicks) {
|
if (options.useNicks) {
|
||||||
if (nick) {
|
if (options.nick) {
|
||||||
roomjid += '/' + nick;
|
roomjid += '/' + options.nick;
|
||||||
} else {
|
} else {
|
||||||
roomjid += '/' + Strophe.getNodeFromJid(this.connection.jid);
|
roomjid += '/' + Strophe.getNodeFromJid(this.connection.jid);
|
||||||
}
|
}
|
||||||
|
|
|
@ -612,10 +612,6 @@ UI.updateRemoteStats = function (jid, percent, stats) {
|
||||||
VideoLayout.updateConnectionStats(jid, percent, stats);
|
VideoLayout.updateConnectionStats(jid, percent, stats);
|
||||||
};
|
};
|
||||||
|
|
||||||
UI.showAuthenticateButton = function (show) {
|
|
||||||
Toolbar.showAuthenticateButton(show);
|
|
||||||
};
|
|
||||||
|
|
||||||
UI.markVideoInterrupted = function (interrupted) {
|
UI.markVideoInterrupted = function (interrupted) {
|
||||||
if (interrupted) {
|
if (interrupted) {
|
||||||
VideoLayout.onVideoInterrupted();
|
VideoLayout.onVideoInterrupted();
|
||||||
|
@ -740,4 +736,15 @@ UI.notifyTokenAuthFailed = function () {
|
||||||
messageHandler.showError("dialog.error", "dialog.tokenAuthFailed");
|
messageHandler.showError("dialog.error", "dialog.tokenAuthFailed");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
UI.updateAuthInfo = function (isAuthEnabled, login) {
|
||||||
|
let loggedIn = !!login;
|
||||||
|
|
||||||
|
if (isAuthEnabled) {
|
||||||
|
Toolbar.setAuthenticatedIdentity(login);
|
||||||
|
|
||||||
|
Toolbar.showLoginButton(!loggedIn);
|
||||||
|
Toolbar.showLogoutButton(loggedIn);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = UI;
|
module.exports = UI;
|
||||||
|
|
|
@ -13,22 +13,53 @@ function getPasswordInputHtml() {
|
||||||
<h2 data-i18n="dialog.passwordRequired">${passRequiredMsg}</h2>
|
<h2 data-i18n="dialog.passwordRequired">${passRequiredMsg}</h2>
|
||||||
<input name="username" type="text" placeholder=${placeholder} autofocus>
|
<input name="username" type="text" placeholder=${placeholder} autofocus>
|
||||||
<input name="password" type="password"
|
<input name="password" type="password"
|
||||||
data-i18n="[placeholder]dialog.userPassword"
|
data-i18n="[placeholder]dialog.userPassword"
|
||||||
placeholder="user password">
|
placeholder="user password">
|
||||||
`;
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function toJid(id) {
|
||||||
|
if (id.indexOf("@") >= 0) {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
let jid = id.concat('@');
|
||||||
|
if (config.hosts.authdomain) {
|
||||||
|
jid += config.hosts.authdomain;
|
||||||
|
} else {
|
||||||
|
jid += config.hosts.domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
return jid;
|
||||||
|
}
|
||||||
|
|
||||||
|
function cancelButton() {
|
||||||
|
return {
|
||||||
|
title: APP.translation.generateTranslationHTML("dialog.Cancel"),
|
||||||
|
value: false
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function Dialog(successCallback, cancelCallback) {
|
function Dialog(successCallback, cancelCallback) {
|
||||||
|
let loginButtons = [{
|
||||||
|
title: APP.translation.generateTranslationHTML("dialog.Ok"),
|
||||||
|
value: true
|
||||||
|
}];
|
||||||
|
let finishedButtons = [{
|
||||||
|
title: APP.translation.translateString('dialog.retry'),
|
||||||
|
value: 'retry'
|
||||||
|
}];
|
||||||
|
|
||||||
|
// show "cancel" button only if cancelCallback provided
|
||||||
|
if (cancelCallback) {
|
||||||
|
loginButtons.push(cancelButton());
|
||||||
|
finishedButtons.push(cancelButton());
|
||||||
|
}
|
||||||
|
|
||||||
const states = {
|
const states = {
|
||||||
login: {
|
login: {
|
||||||
html: getPasswordInputHtml(),
|
html: getPasswordInputHtml(),
|
||||||
buttons: [{
|
buttons: loginButtons,
|
||||||
title: APP.translation.generateTranslationHTML("dialog.Ok"),
|
|
||||||
value: true
|
|
||||||
}, {
|
|
||||||
title: APP.translation.generateTranslationHTML("dialog.Cancel"),
|
|
||||||
value: false
|
|
||||||
}],
|
|
||||||
focus: ':input:first',
|
focus: ':input:first',
|
||||||
submit: function (e, v, m, f) {
|
submit: function (e, v, m, f) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -37,7 +68,7 @@ function Dialog(successCallback, cancelCallback) {
|
||||||
let password = f.password;
|
let password = f.password;
|
||||||
if (jid && password) {
|
if (jid && password) {
|
||||||
connDialog.goToState('connecting');
|
connDialog.goToState('connecting');
|
||||||
successCallback(jid, password);
|
successCallback(toJid(jid), password);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// User cancelled
|
// User cancelled
|
||||||
|
@ -54,13 +85,7 @@ function Dialog(successCallback, cancelCallback) {
|
||||||
finished: {
|
finished: {
|
||||||
title: APP.translation.translateString('dialog.error'),
|
title: APP.translation.translateString('dialog.error'),
|
||||||
html: '<div id="errorMessage"></div>',
|
html: '<div id="errorMessage"></div>',
|
||||||
buttons: [{
|
buttons: finishedButtons,
|
||||||
title: APP.translation.translateString('dialog.retry'),
|
|
||||||
value: 'retry'
|
|
||||||
}, {
|
|
||||||
title: APP.translation.generateTranslationHTML("dialog.Cancel"),
|
|
||||||
value: false
|
|
||||||
}],
|
|
||||||
defaultButton: 0,
|
defaultButton: 0,
|
||||||
submit: function (e, v, m, f) {
|
submit: function (e, v, m, f) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
|
@ -5,7 +5,7 @@ import LoginDialog from './UI/authentication/LoginDialog';
|
||||||
const ConnectionEvents = JitsiMeetJS.events.connection;
|
const ConnectionEvents = JitsiMeetJS.events.connection;
|
||||||
const ConnectionErrors = JitsiMeetJS.errors.connection;
|
const ConnectionErrors = JitsiMeetJS.errors.connection;
|
||||||
|
|
||||||
export function openConnection({retry, id, password}) {
|
function connect(id, password) {
|
||||||
let connection = new JitsiMeetJS.JitsiConnection(null, null, {
|
let connection = new JitsiMeetJS.JitsiConnection(null, null, {
|
||||||
hosts: config.hosts,
|
hosts: config.hosts,
|
||||||
bosh: config.bosh,
|
bosh: config.bosh,
|
||||||
|
@ -17,9 +17,8 @@ export function openConnection({retry, id, password}) {
|
||||||
ConnectionEvents.CONNECTION_ESTABLISHED, handleConnectionEstablished
|
ConnectionEvents.CONNECTION_ESTABLISHED, handleConnectionEstablished
|
||||||
);
|
);
|
||||||
connection.addEventListener(
|
connection.addEventListener(
|
||||||
ConnectionEvents.CONNECTION_FAILED, onConnectionFailed
|
ConnectionEvents.CONNECTION_FAILED, handleConnectionFailed
|
||||||
);
|
);
|
||||||
let authDialog;
|
|
||||||
|
|
||||||
function unsubscribe() {
|
function unsubscribe() {
|
||||||
connection.removeEventListener(
|
connection.removeEventListener(
|
||||||
|
@ -27,11 +26,9 @@ export function openConnection({retry, id, password}) {
|
||||||
handleConnectionEstablished
|
handleConnectionEstablished
|
||||||
);
|
);
|
||||||
connection.removeEventListener(
|
connection.removeEventListener(
|
||||||
ConnectionEvents.CONNECTION_FAILED, onConnectionFailed
|
ConnectionEvents.CONNECTION_FAILED,
|
||||||
|
handleConnectionFailed
|
||||||
);
|
);
|
||||||
if (authDialog) {
|
|
||||||
authDialog.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleConnectionEstablished() {
|
function handleConnectionEstablished() {
|
||||||
|
@ -41,43 +38,49 @@ export function openConnection({retry, id, password}) {
|
||||||
|
|
||||||
function handleConnectionFailed(err) {
|
function handleConnectionFailed(err) {
|
||||||
unsubscribe();
|
unsubscribe();
|
||||||
|
console.error("CONNECTION FAILED:", err);
|
||||||
reject(err);
|
reject(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onConnectionFailed (err) {
|
connection.connect({id, password});
|
||||||
console.error("CONNECTION FAILED:", err);
|
});
|
||||||
|
}
|
||||||
if (!retry) {
|
|
||||||
handleConnectionFailed(err);
|
function requestAuth() {
|
||||||
return;
|
return new Promise(function (resolve, reject) {
|
||||||
}
|
let authDialog = LoginDialog.showAuthDialog(
|
||||||
|
function (id, password) {
|
||||||
// retry only if auth failed
|
connect(id, password).then(function (connection) {
|
||||||
if (err !== ConnectionErrors.PASSWORD_REQUIRED) {
|
authDialog.close();
|
||||||
handleConnectionFailed(err);
|
resolve(connection);
|
||||||
return;
|
}, function (err) {
|
||||||
}
|
if (err === ConnectionErrors.PASSWORD_REQUIRED) {
|
||||||
|
authDialog.displayError(err);
|
||||||
// do not retry if token is not valid
|
} else {
|
||||||
if (config.token) {
|
authDialog.close();
|
||||||
handleConnectionFailed(err);
|
reject(err);
|
||||||
return;
|
}
|
||||||
}
|
});
|
||||||
|
}
|
||||||
// ask for password and try again
|
);
|
||||||
|
});
|
||||||
if (authDialog) {
|
}
|
||||||
authDialog.displayError(err);
|
|
||||||
return;
|
export function openConnection({id, password, retry}) {
|
||||||
}
|
return connect(id, password).catch(function (err) {
|
||||||
|
if (!retry) {
|
||||||
authDialog = LoginDialog.showAuthDialog(
|
throw err;
|
||||||
function (id, password) {
|
}
|
||||||
connection.connect({id, password});
|
|
||||||
}
|
if (err === ConnectionErrors.PASSWORD_REQUIRED) {
|
||||||
);
|
// do not retry if token is not valid
|
||||||
}
|
if (config.token) {
|
||||||
|
throw err;
|
||||||
connection.connect(id, password);
|
} else {
|
||||||
|
return requestAuth();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,7 @@ module.exports = {
|
||||||
|
|
||||||
init: function () {
|
init: function () {
|
||||||
// Called when RTC finishes initialization
|
// Called when RTC finishes initialization
|
||||||
|
return;
|
||||||
APP.RTC.addListener(RTCEvents.RTC_READY,
|
APP.RTC.addListener(RTCEvents.RTC_READY,
|
||||||
function() {
|
function() {
|
||||||
screenObtainer.init(eventEmitter);
|
screenObtainer.init(eventEmitter);
|
||||||
|
|
|
@ -86,6 +86,7 @@ var statistics = {
|
||||||
stopRemote();
|
stopRemote();
|
||||||
},
|
},
|
||||||
start: function () {
|
start: function () {
|
||||||
|
return;
|
||||||
APP.RTC.addStreamListener(onStreamCreated,
|
APP.RTC.addStreamListener(onStreamCreated,
|
||||||
StreamEventTypes.EVENT_TYPE_LOCAL_CREATED);
|
StreamEventTypes.EVENT_TYPE_LOCAL_CREATED);
|
||||||
APP.xmpp.addListener(XMPPEvents.DISPOSE_CONFERENCE,
|
APP.xmpp.addListener(XMPPEvents.DISPOSE_CONFERENCE,
|
||||||
|
|
Loading…
Reference in New Issue