|
@@ -120,21 +120,23 @@ export default class PingConnectionPlugin extends ConnectionPlugin {
|
120
|
120
|
// when there were some server responses in the interval since the last time we checked (_lastServerCheck)
|
121
|
121
|
// let's skip the ping
|
122
|
122
|
|
123
|
|
- // server response is measured on raw input and ping response time is measured after all the xmpp
|
124
|
|
- // processing is done, and when the last server response is a ping there can be slight misalignment of the
|
125
|
|
- // times, we give it 100ms for that processing.
|
126
|
|
- if (this._getTimeSinceLastServerResponse() + 100 < new Date() - this._lastServerCheck) {
|
|
123
|
+ const now = Date.now();
|
|
124
|
+
|
|
125
|
+ if (this._getTimeSinceLastServerResponse() < now - this._lastServerCheck) {
|
127
|
126
|
// do this just to keep in sync the intervals so we can detect suspended device
|
128
|
127
|
this._addPingExecutionTimestamp();
|
129
|
128
|
|
130
|
|
- this._lastServerCheck = new Date();
|
|
129
|
+ this._lastServerCheck = now;
|
131
|
130
|
this.failedPings = 0;
|
132
|
131
|
|
133
|
132
|
return;
|
134
|
133
|
}
|
135
|
134
|
|
136
|
135
|
this.ping(remoteJid, () => {
|
137
|
|
- this._lastServerCheck = new Date();
|
|
136
|
+ // server response is measured on raw input and ping response time is measured after all the xmpp
|
|
137
|
+ // processing is done in js, so there can be some misalignment when we do the check above.
|
|
138
|
+ // That's why we store the last time we got the response
|
|
139
|
+ this._lastServerCheck = this._getTimeSinceLastServerResponse() + Date.now();
|
138
|
140
|
|
139
|
141
|
this.failedPings = 0;
|
140
|
142
|
}, error => {
|