mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Clear and reset all relevant timers on packet
Not clear to me that receiving a pong would actually clear the old heartbeat timer.
This commit is contained in:
@@ -79,24 +79,30 @@ _.extend(DDPCommon.Heartbeat.prototype, {
|
||||
self._onTimeout();
|
||||
},
|
||||
|
||||
pingReceived: function () {
|
||||
// Restart all timers, as we got a message from the counterparty.
|
||||
_restartTimers: function () {
|
||||
var self = this;
|
||||
// We know the connection is alive if we receive a ping, so we
|
||||
// don't need to send a ping ourselves. Reset the interval timer.
|
||||
if (self._heartbeatTimeoutHandle) {
|
||||
self._clearHeartbeatTimeoutTimer();
|
||||
}
|
||||
if (self._heartbeatIntervalHandle) {
|
||||
self._clearHeartbeatIntervalTimer();
|
||||
self._startHeartbeatIntervalTimer();
|
||||
}
|
||||
},
|
||||
|
||||
pingReceived: function () {
|
||||
var self = this;
|
||||
// We know the connection is alive if we receive a ping, so we
|
||||
// don't need to send a ping ourselves. Reset the interval timer.
|
||||
self._restartTimers();
|
||||
},
|
||||
|
||||
pongReceived: function () {
|
||||
var self = this;
|
||||
|
||||
// Receiving a pong means we won't timeout, so clear the timeout
|
||||
// timer and start the interval again.
|
||||
if (self._heartbeatTimeoutHandle) {
|
||||
self._clearHeartbeatTimeoutTimer();
|
||||
self._startHeartbeatIntervalTimer();
|
||||
}
|
||||
self._restartTimers();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user