Selaa lähdekoodia

ref(xmpp): move BOSH last success tracker to XmppConnection

master
paweldomas 5 vuotta sitten
vanhempi
commit
a5beb689d9
2 muutettua tiedostoa jossa 19 lisäystä ja 5 poistoa
  1. 18
    0
      modules/xmpp/XmppConnection.js
  2. 1
    5
      modules/xmpp/xmpp.js

+ 18
- 0
modules/xmpp/XmppConnection.js Näytä tiedosto

@@ -1,6 +1,8 @@
1 1
 import { getLogger } from 'jitsi-meet-logger';
2 2
 import { $pres, Strophe } from 'strophe.js';
3 3
 
4
+import LastSuccessTracker from './StropheBoshLastSuccess';
5
+
4 6
 const logger = getLogger(__filename);
5 7
 
6 8
 /**
@@ -20,6 +22,11 @@ export default class XmppConnection {
20 22
 
21 23
         // The default maxRetries is 5, which is too long.
22 24
         this._stropheConn.maxRetries = 3;
25
+
26
+        if (!this._usesWebsocket) {
27
+            this._lastSuccessTracker = new LastSuccessTracker();
28
+            this._lastSuccessTracker.startTracking(this._stropheConn);
29
+        }
23 30
     }
24 31
 
25 32
     /**
@@ -223,6 +230,17 @@ export default class XmppConnection {
223 230
         this._stropheConn.flush(...args);
224 231
     }
225 232
 
233
+    /**
234
+     * See {@link LastRequestTracker.getTimeSinceLastSuccess}.
235
+     *
236
+     * @returns {number|null}
237
+     */
238
+    getTimeSinceLastBOSHSuccess() {
239
+        return this._lastSuccessTracker
240
+            ? this._lastSuccessTracker.getTimeSinceLastSuccess()
241
+            : null;
242
+    }
243
+
226 244
     /**
227 245
      * Send a stanza. This function is called to push data onto the send queue to go out over the wire.
228 246
      *

+ 1
- 5
modules/xmpp/xmpp.js Näytä tiedosto

@@ -14,7 +14,6 @@ import initStropheUtil from './strophe.util';
14 14
 import initPing from './strophe.ping';
15 15
 import initRayo from './strophe.rayo';
16 16
 import initStropheLogger from './strophe.logger';
17
-import LastSuccessTracker from './StropheBoshLastSuccess';
18 17
 import Listenable from '../util/Listenable';
19 18
 import Caps from './Caps';
20 19
 import GlobalOnErrorHandler from '../util/GlobalOnErrorHandler';
@@ -88,9 +87,6 @@ export default class XMPP extends Listenable {
88 87
 
89 88
         this.connection = createConnection(this, token, serviceUrl);
90 89
 
91
-        this._lastSuccessTracker = new LastSuccessTracker();
92
-        this._lastSuccessTracker.startTracking(this.connection);
93
-
94 90
         this.caps = new Caps(this.connection, this.options.clientNode);
95 91
 
96 92
         // Initialize features advertised in disco-info
@@ -642,7 +638,7 @@ export default class XMPP extends Listenable {
642 638
         /* eslint-disable camelcase */
643 639
         // check for possible suspend
644 640
         details.suspend_time = this.connection.ping.getPingSuspendTime();
645
-        details.time_since_last_success = this._lastSuccessTracker.getTimeSinceLastSuccess();
641
+        details.time_since_last_success = this.connection.getTimeSinceLastBOSHSuccess();
646 642
         /* eslint-enable camelcase */
647 643
 
648 644
         return details;

Loading…
Peruuta
Tallenna