Permalink
Browse files

Fix ping mechanism

  • Loading branch information...
1 parent a417006 commit 2e027ea391440d1fdd65e792ac495965d4eb5110 @mscdex committed Oct 11, 2012
Showing with 7 additions and 7 deletions.
  1. +7 −7 lib/Client.js
View
@@ -255,11 +255,6 @@ Client.prototype.prepare = function(query) {
return function() { return query; };
}
-Client.prototype._ping = function() {
- this.query('DO 0', true, true);
- this._pinger = setTimeout(this._ping, this.pingInterval);
-};
-
Client.prototype._reset = function() {
clearTimeout(this._pinger);
this._closeOnEmpty = false;
@@ -276,8 +271,13 @@ Client.prototype._processQueries = function() {
this._client.query(this._curResults._query, this._curResults._useArray);
} else if (this._closeOnEmpty)
this.destroy();
- else
- this._pinger = setTimeout(this._ping, this.pingInterval);
+ else {
+ var self = this;
+ this._pinger = setTimeout(function ping() {
+ self.query('DO 0', true, true);
+ self._pinger = setTimeout(ping, self.pingInterval);
+ }, this.pingInterval);
+ }
}
};

0 comments on commit 2e027ea

Please sign in to comment.