Index: remoting/webapp/session_connector.js |
diff --git a/remoting/webapp/session_connector.js b/remoting/webapp/session_connector.js |
index 86eff44973ff2bc36eada5ab96d9c0039c0309ef..ac8a2ae270f26fb6b04aa1518b663fea47fb9eb8 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_, |