|
@@ -12,13 +12,18 @@ export default class LastRequestTracker {
|
12
|
12
|
/**
|
13
|
13
|
* Starts tracking requests on the given connection.
|
14
|
14
|
*
|
|
15
|
+ * @param {XmppConnection} xmppConnection - The XMPP connection which manages the given {@code stropheConnection}.
|
15
|
16
|
* @param {Object} stropheConnection - Strophe connection instance.
|
16
|
17
|
*/
|
17
|
|
- startTracking(stropheConnection) {
|
|
18
|
+ startTracking(xmppConnection, stropheConnection) {
|
18
|
19
|
const originalRawInput = stropheConnection.rawInput;
|
19
|
20
|
|
20
|
|
- stropheConnection.rawInput = function(...args) {
|
21
|
|
- this._lastSuccess = Date.now();
|
|
21
|
+ stropheConnection.rawInput = (...args) => {
|
|
22
|
+ // It's okay to use rawInput callback only once the connection has been established, otherwise it will
|
|
23
|
+ // treat 'item-not-found' or other connection error on websocket reconnect as successful stanza received.
|
|
24
|
+ if (xmppConnection.connected) {
|
|
25
|
+ this._lastSuccess = Date.now();
|
|
26
|
+ }
|
22
|
27
|
originalRawInput.apply(stropheConnection, args);
|
23
|
28
|
};
|
24
|
29
|
}
|