diff options
-rw-r--r-- | remoting/webapp/session_connector.js | 12 | ||||
-rw-r--r-- | remoting/webapp/wcs_sandbox_container.js | 18 | ||||
-rw-r--r-- | remoting/webapp/wcs_sandbox_content.js | 6 |
3 files changed, 23 insertions, 13 deletions
diff --git a/remoting/webapp/session_connector.js b/remoting/webapp/session_connector.js index 86eff44..ac8a2ae 100644 --- a/remoting/webapp/session_connector.js +++ b/remoting/webapp/session_connector.js @@ -317,7 +317,7 @@ remoting.SessionConnector.prototype.onIT2MeHostInfo_ = function(xhr) { * @private */ remoting.SessionConnector.prototype.loadWcs_ = function(token) { - remoting.wcsSandbox.setOnReady(this.onWcsLoaded_.bind(this)); + remoting.wcsSandbox.setOnLocalJid(this.onLocalJid_.bind(this)); remoting.wcsSandbox.setOnError(this.onError_); remoting.wcsSandbox.setAccessToken(token); this.startAccessTokenRefreshTimer_(); @@ -330,7 +330,7 @@ remoting.SessionConnector.prototype.loadWcs_ = function(token) { * @return {void} Nothing. * @private */ -remoting.SessionConnector.prototype.onWcsLoaded_ = function(clientJid) { +remoting.SessionConnector.prototype.onLocalJid_ = function(clientJid) { this.clientJid_ = clientJid; this.createSessionIfReady_(); }; @@ -346,6 +346,14 @@ remoting.SessionConnector.prototype.createSessionIfReady_ = function() { return; } + // In some circumstances, the WCS <iframe> can get reloaded, which results + // in a new clientJid and a new callback. In this case, remove the old + // client plugin before instantiating a new one. + if (this.clientSession_) { + this.clientSession_.removePlugin(); + this.clientSession_ = null; + } + var securityTypes = 'third_party,spake2_pair,spake2_hmac,spake2_plain'; this.clientSession_ = new remoting.ClientSession( this.hostJid_, this.clientJid_, this.hostPublicKey_, this.passPhrase_, diff --git a/remoting/webapp/wcs_sandbox_container.js b/remoting/webapp/wcs_sandbox_container.js index 68f2fbd..e47421e 100644 --- a/remoting/webapp/wcs_sandbox_container.js +++ b/remoting/webapp/wcs_sandbox_container.js @@ -22,7 +22,7 @@ var remoting = remoting || {}; remoting.WcsSandboxContainer = function(sandbox) { this.sandbox_ = sandbox; /** @type {?function(string):void} */ - this.onReady_ = null; + this.onLocalJid_ = null; /** @type {?function(remoting.Error):void} */ this.onError_ = null; /** @type {?function(string):void} */ @@ -34,12 +34,14 @@ remoting.WcsSandboxContainer = function(sandbox) { }; /** - * @param {?function(string):void} onReady Callback invoked with the client JID - * when the WCS code has loaded. + * @param {?function(string):void} onLocalJid Callback invoked with the client + * JID when the WCS code has loaded. Note that this may be called more than + * once (potentially with a different JID) if the WCS node is reloaded for + * any reason. * @return {void} Nothing. */ -remoting.WcsSandboxContainer.prototype.setOnReady = function(onReady) { - this.onReady_ = onReady; +remoting.WcsSandboxContainer.prototype.setOnLocalJid = function(onLocalJid) { + this.onLocalJid_ = onLocalJid; }; /** @@ -92,15 +94,15 @@ remoting.WcsSandboxContainer.prototype.sendIq = function(stanza) { remoting.WcsSandboxContainer.prototype.onMessage_ = function(event) { switch (event.data['command']) { - case 'onReady': + case 'onLocalJid': /** @type {string} */ var clientJid = event.data['clientJid']; if (clientJid === undefined) { console.error('onReady: missing client JID'); break; } - if (this.onReady_) { - this.onReady_(clientJid); + if (this.onLocalJid_) { + this.onLocalJid_(clientJid); } break; diff --git a/remoting/webapp/wcs_sandbox_content.js b/remoting/webapp/wcs_sandbox_content.js index b97f6a4..8de4663 100644 --- a/remoting/webapp/wcs_sandbox_content.js +++ b/remoting/webapp/wcs_sandbox_content.js @@ -75,7 +75,7 @@ remoting.WcsSandboxContent.prototype.onMessage_ = function(event) { } else if (!remoting.wcsLoader) { remoting.wcsLoader = new remoting.WcsLoader(); remoting.wcsLoader.start(token, - this.onReady_.bind(this), + this.onLocalJid_.bind(this), this.onError_.bind(this)); } break; @@ -121,10 +121,10 @@ remoting.WcsSandboxContent.prototype.onMessage_ = function(event) { * @param {string} clientJid The full JID of the WCS client. * @private */ -remoting.WcsSandboxContent.prototype.onReady_ = function(clientJid) { +remoting.WcsSandboxContent.prototype.onLocalJid_ = function(clientJid) { remoting.wcs.setOnIq(this.onIq_.bind(this)); var message = { - 'command': 'onReady', + 'command': 'onLocalJid', 'clientJid': clientJid }; this.parentWindow_.postMessage(message, '*'); |