Browse Source

Allows testing how synchronous and asynchronous Strophe affects the reliability of the delivery of unavailable presence to the XMPP server.

dev1
Lyubomir Marinov 9 years ago
parent
commit
21d5049076
4 changed files with 14061 additions and 13830 deletions
  1. 7
    1
      JitsiConnection.js
  2. 14013
    13811
      lib-jitsi-meet.js
  3. 16
    16
      lib-jitsi-meet.min.js
  4. 25
    2
      modules/xmpp/xmpp.js

+ 7
- 1
JitsiConnection.js View File

@@ -32,7 +32,13 @@ JitsiConnection.prototype.connect = function (options) {
32 32
  * Disconnect the client from the server.
33 33
  */
34 34
 JitsiConnection.prototype.disconnect = function () {
35
-    this.xmpp.disconnect();
35
+    // XXX Forward any arguments passed to JitsiConnection.disconnect to
36
+    // XMPP.disconnect. For example, the caller of JitsiConnection.disconnect
37
+    // may optionally pass the event which triggered the disconnect in order to
38
+    // provide the implementation with finer-grained context.
39
+    var x = this.xmpp;
40
+
41
+    x.disconnect.apply(x, arguments);
36 42
 }
37 43
 
38 44
 /**

+ 14013
- 13811
lib-jitsi-meet.js
File diff suppressed because it is too large
View File


+ 16
- 16
lib-jitsi-meet.min.js
File diff suppressed because it is too large
View File


+ 25
- 2
modules/xmpp/xmpp.js View File

@@ -290,7 +290,13 @@ XMPP.prototype.getSessions = function () {
290 290
     return this.connection.jingle.sessions;
291 291
 };
292 292
 
293
-XMPP.prototype.disconnect = function () {
293
+/**
294
+ * Disconnects this from the XMPP server (if this is connected).
295
+ *
296
+ * @param ev optionally, the event which triggered the necessity to disconnect
297
+ * from the XMPP server (e.g. beforeunload, unload)
298
+ */
299
+XMPP.prototype.disconnect = function (ev) {
294 300
     if (this.disconnectInProgress
295 301
             || !this.connection
296 302
             || !this.connection.connected) {
@@ -312,8 +318,25 @@ XMPP.prototype.disconnect = function () {
312 318
     // once more after disconnect() in order to attempt to have its unavailable
313 319
     // presence sent as soon as possible.
314 320
     this.connection.flush();
321
+
322
+    if (ev !== null && typeof ev !== 'undefined') {
323
+        var evType = ev.type;
324
+
325
+        if (evType == 'beforeunload' || evType == 'unload') {
326
+            // XXX Whatever we said above, synchronous sending is the best
327
+            // (known) way to properly disconnect from the XMPP server.
328
+            // Consequently, it may be fine to have the source code and comment
329
+            // it in or out depending on whether we want to run with it for some
330
+            // time.
331
+            this.connection.options.sync = true;
332
+        }
333
+    }
334
+
315 335
     this.connection.disconnect();
316
-    this.connection.flush();
336
+
337
+    if (this.connection.options.sync !== true) {
338
+        this.connection.flush();
339
+    }
317 340
 };
318 341
 
319 342
 module.exports = XMPP;

Loading…
Cancel
Save