From e16cee4187475ac5abb3934953d97976b24c1efd Mon Sep 17 00:00:00 2001 From: paweldomas Date: Thu, 19 Feb 2015 13:56:04 +0100 Subject: [PATCH] Delete old session ID and retry on 'session-invalid' response. Updates app.bundle.js. --- index.html | 2 +- libs/app.bundle.js | 46 ++++++++++++++++++++++----------------- modules/xmpp/moderator.js | 42 +++++++++++++++++++---------------- 3 files changed, 50 insertions(+), 40 deletions(-) diff --git a/index.html b/index.html index 865b32cc7..0418088c0 100644 --- a/index.html +++ b/index.html @@ -19,7 +19,7 @@ - + diff --git a/libs/app.bundle.js b/libs/app.bundle.js index ddedea378..dbf47f218 100644 --- a/libs/app.bundle.js +++ b/libs/app.bundle.js @@ -627,7 +627,7 @@ var DataChannels = // selections so that it can do adaptive simulcast, // we want the notification to trigger even if userJid is undefined, // or null. - var userJid = APP.UI.getLargeVideoState().userJid; + var userJid = APP.UI.getLargeVideoState().userResourceJid; // we want the notification to trigger even if userJid is undefined, // or null. onSelectedEndpointChanged(userJid); @@ -785,6 +785,8 @@ function onSelectedEndpointChanged(userResource) _dataChannels.some(function (dataChannel) { if (dataChannel.readyState == 'open') { + console.log('sending selected endpoint changed ' + + 'notification to the bridge: ', userResource); dataChannel.send(JSON.stringify({ 'colibriClass': 'SelectedEndpointChangedEvent', 'selectedEndpoint': @@ -14695,7 +14697,7 @@ module.exports = TraceablePeerConnection; },{}],53:[function(require,module,exports){ -/* global $, $iq, config, connection, UI, messageHandler, +/* global $, $iq, APP, config, connection, UI, messageHandler, roomName, sessionTerminated, Strophe, Util */ var XMPPEvents = require("../../service/xmpp/XMPPEvents"); var Settings = require("../settings/Settings"); @@ -14964,45 +14966,49 @@ var Moderator = { } }, function (error) { + // Invalid session ? remove and try again + // without session ID to get a new one + var invalidSession + = $(error).find('>error>session-invalid').length; + if (invalidSession) { + console.info("Session expired! - removing"); + localStorage.removeItem("sessionId"); + } // Not authorized to create new room if ($(error).find('>error>not-authorized').length) { console.warn("Unauthorized to start the conference", error); - - if ($(error).find('>error>session-invalid').length) { - // FIXME: just retry - console.info("Session expired! - removing"); - localStorage.removeItem("sessionId"); - } - var toDomain = Strophe.getDomainFromJid(error.getAttribute('to')); if (toDomain === config.hosts.anonymousdomain) { // we are connected with anonymous domain and // only non anonymous users can create rooms // we must authorize the user - self.xmppService.promptLogin(); } else { - - eventEmitter.emit(XMPPEvents.AUTHENTICATION_REQUIRED, // External authentication mode + // External authentication mode + eventEmitter.emit( + XMPPEvents.AUTHENTICATION_REQUIRED, function () { Moderator.allocateConferenceFocus( roomName, callback); }); - } return; } var waitMs = getNextErrorTimeout(); console.error("Focus error, retry after " + waitMs, error); // Show message - APP.UI.messageHandler.notify( null, "notify.focus", - 'Conference focus', 'disconnected',"notify.focusFail", - Moderator.getFocusComponent() + - ' not available - retry in ' + - (waitMs / 1000) + ' sec', - {component: Moderator.getFocusComponent(), - ms: (waitMs / 1000)}); + var focusComponent = Moderator.getFocusComponent(); + var retrySec = waitMs / 1000; + // FIXME: message is duplicated ? + // Do not show in case of session invalid + // which means just a retry + if (!invalidSession) { + APP.UI.messageHandler.notify( + null, "notify.focus", + 'Conference focus', 'disconnected', "notify.focusFail", + {component: focusComponent, ms: retrySec}); + } // Reset response timeout getNextTimeout(true); window.setTimeout( diff --git a/modules/xmpp/moderator.js b/modules/xmpp/moderator.js index 322815ca0..ed8ebdb71 100644 --- a/modules/xmpp/moderator.js +++ b/modules/xmpp/moderator.js @@ -1,4 +1,4 @@ -/* global $, $iq, config, connection, UI, messageHandler, +/* global $, $iq, APP, config, connection, UI, messageHandler, roomName, sessionTerminated, Strophe, Util */ var XMPPEvents = require("../../service/xmpp/XMPPEvents"); var Settings = require("../settings/Settings"); @@ -267,45 +267,49 @@ var Moderator = { } }, function (error) { + // Invalid session ? remove and try again + // without session ID to get a new one + var invalidSession + = $(error).find('>error>session-invalid').length; + if (invalidSession) { + console.info("Session expired! - removing"); + localStorage.removeItem("sessionId"); + } // Not authorized to create new room if ($(error).find('>error>not-authorized').length) { console.warn("Unauthorized to start the conference", error); - - if ($(error).find('>error>session-invalid').length) { - // FIXME: just retry - console.info("Session expired! - removing"); - localStorage.removeItem("sessionId"); - } - var toDomain = Strophe.getDomainFromJid(error.getAttribute('to')); if (toDomain === config.hosts.anonymousdomain) { // we are connected with anonymous domain and // only non anonymous users can create rooms // we must authorize the user - self.xmppService.promptLogin(); } else { - - eventEmitter.emit(XMPPEvents.AUTHENTICATION_REQUIRED, // External authentication mode + // External authentication mode + eventEmitter.emit( + XMPPEvents.AUTHENTICATION_REQUIRED, function () { Moderator.allocateConferenceFocus( roomName, callback); }); - } return; } var waitMs = getNextErrorTimeout(); console.error("Focus error, retry after " + waitMs, error); // Show message - APP.UI.messageHandler.notify( null, "notify.focus", - 'Conference focus', 'disconnected',"notify.focusFail", - Moderator.getFocusComponent() + - ' not available - retry in ' + - (waitMs / 1000) + ' sec', - {component: Moderator.getFocusComponent(), - ms: (waitMs / 1000)}); + var focusComponent = Moderator.getFocusComponent(); + var retrySec = waitMs / 1000; + // FIXME: message is duplicated ? + // Do not show in case of session invalid + // which means just a retry + if (!invalidSession) { + APP.UI.messageHandler.notify( + null, "notify.focus", + 'Conference focus', 'disconnected', "notify.focusFail", + {component: focusComponent, ms: retrySec}); + } // Reset response timeout getNextTimeout(true); window.setTimeout(