Przeglądaj źródła

fix: Fixes ping options usage.

Due to no timeout value passed the disconnection was not detected.
dev1
damencho 4 lat temu
rodzic
commit
3516123210
1 zmienionych plików z 3 dodań i 18 usunięć
  1. 3
    18
      modules/xmpp/strophe.ping.js

+ 3
- 18
modules/xmpp/strophe.ping.js Wyświetl plik

@@ -25,21 +25,6 @@ const PING_DEFAULT_TIMEOUT = 5000;
25 25
  */
26 26
 const PING_DEFAULT_THRESHOLD = 2;
27 27
 
28
-/**
29
- * How often to send ping requests.
30
- */
31
-let pingInterval;
32
-
33
-/**
34
- * The time to wait for ping responses.
35
- */
36
-let pingTimeout;
37
-
38
-/**
39
- * How many ping failures will be tolerated before the connection is killed.
40
- */
41
-let pingThreshold;
42
-
43 28
 /**
44 29
  * XEP-0199 ping plugin.
45 30
  *
@@ -143,14 +128,14 @@ export default class PingConnectionPlugin extends ConnectionPlugin {
143 128
                 this.failedPings += 1;
144 129
                 const errmsg = `Ping ${error ? 'error' : 'timeout'}`;
145 130
 
146
-                if (this.failedPings >= pingThreshold) {
131
+                if (this.failedPings >= this.pingThreshold) {
147 132
                     GlobalOnErrorHandler.callErrorHandler(new Error(errmsg));
148 133
                     logger.error(errmsg, error);
149 134
                     this._onPingThresholdExceeded && this._onPingThresholdExceeded();
150 135
                 } else {
151 136
                     logger.warn(errmsg, error);
152 137
                 }
153
-            }, pingTimeout);
138
+            }, this.pingTimeout);
154 139
         }, this.pingInterval);
155 140
         logger.info(`XMPP pings will be sent every ${this.pingInterval} ms`);
156 141
     }
@@ -213,7 +198,7 @@ export default class PingConnectionPlugin extends ConnectionPlugin {
213 198
         // remove the interval between the ping sent
214 199
         // this way in normal execution there is no suspend and the return
215 200
         // will be 0 or close to 0.
216
-        maxInterval -= pingInterval;
201
+        maxInterval -= this.pingInterval;
217 202
 
218 203
         // make sure we do not return less than 0
219 204
         return Math.max(maxInterval, 0);

Ładowanie…
Anuluj
Zapisz