Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

Fixes conference disposal in FF.

George Politisb9f00b71b2f4
diff --git a/modules/xmpp/xmpp.js b/modules/xmpp/xmpp.js
index 5e839d9615..e0b746cb2f 100644
--- a/modules/xmpp/xmpp.js
+++ b/modules/xmpp/xmpp.js
@@ -190,8 +190,13 @@ function registerListeners() {
});
}
-function setupEvents() {
- $(window).bind('beforeunload', function () {
+var unload = (function () {
+ var unloaded = false;
+
+ return function () {
+ if (unloaded) { return; }
+ unloaded = true;
+
if (connection && connection.connected) {
// ensure signout
$.ajax({
@@ -200,24 +205,41 @@ function setupEvents() {
async: false,
cache: false,
contentType: 'application/xml',
- data: "<body rid='" + (connection.rid || connection._proto.rid)
- + "' xmlns='http://jabber.org/protocol/httpbind' sid='"
- + (connection.sid || connection._proto.sid)
- + "' type='terminate'>" +
- "<presence xmlns='jabber:client' type='unavailable'/>" +
- "</body>",
+ data: "<body rid='" + (connection.rid || connection._proto.rid) +
+ "' xmlns='http://jabber.org/protocol/httpbind' sid='" +
+ (connection.sid || connection._proto.sid) +
+ "' type='terminate'>" +
+ "<presence xmlns='jabber:client' type='unavailable'/>" +
+ "</body>",
success: function (data) {
console.log('signed out');
console.log(data);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
console.log('signout error',
- textStatus + ' (' + errorThrown + ')');
+ textStatus + ' (' + errorThrown + ')');
}
});
}
XMPP.disposeConference(true);
- });
+ };
+})();
+
+function setupEvents() {
+ // In recent versions of FF the 'beforeunload' event is not fired when the
+ // window or the tab is closed. It is only fired when we leave the page
+ // (change URL). If this participant doesn't unload properly, then it
+ // becomes a ghost for the rest of the participants that stay in the
+ // conference. Thankfully handling the 'unload' event in addition to the
+ // 'beforeunload' event seems to garante the execution of the 'unload'
+ // method at least once.
+ //
+ // The 'unload' method can safely be run multiple times, it will actually do
+ // something only the first time that it's run, so we're don't have to worry
+ // about browsers that fire both events.
+
+ $(window).bind('beforeunload', unload);
+ $(window).bind('unload', unload);
}
var XMPP = {