diff --git a/static/js/mediastream/webrtc.js b/static/js/mediastream/webrtc.js index 4cfe54b0..0d976d7f 100644 --- a/static/js/mediastream/webrtc.js +++ b/static/js/mediastream/webrtc.js @@ -95,6 +95,7 @@ function($, _, PeerCall, PeerConference, PeerXfer, PeerScreenshare, UserMedia, u this.msgQueues = {}; this.usermediaReady = false; this.pendingMediaCalls = []; + this.pendingMessages = []; this.usermedia = null; this.audioMute = false; @@ -174,6 +175,16 @@ function($, _, PeerCall, PeerConference, PeerXfer, PeerScreenshare, UserMedia, u if (this.isConferenceRoom()) { // Switching from a conference room closes all current connections. + this.leavingConference = true; + this.e.one("stop", _.bind(function() { + _.defer(_.bind(function() { + this.leavingConference = false; + while (this.pendingMessages.length) { + var args = this.pendingMessages.shift(); + this.processReceivedMessage.apply(this, args); + } + }, this)); + }, this)); _.defer(_.bind(function() { this.doHangup(); }, this)); @@ -220,6 +231,13 @@ function($, _, PeerCall, PeerConference, PeerXfer, PeerScreenshare, UserMedia, u return; } + if (this.leavingConference) { + // Defer evaluating of messages until the previous conference room + // has been left. + this.pendingMessages.push([to, data, type, to2, from]); + return; + } + this.processReceivedMessage(to, data, type, to2, from); };