commit
5a2f310d90
@ -82,6 +82,7 @@ function Node()
|
|||||||
this._tries = 0;
|
this._tries = 0;
|
||||||
this._down = 0;
|
this._down = 0;
|
||||||
this._lastSent = 0;
|
this._lastSent = 0;
|
||||||
|
this._latency = 0;
|
||||||
|
|
||||||
this.blocks = [];
|
this.blocks = [];
|
||||||
|
|
||||||
@ -106,6 +107,10 @@ function Node()
|
|||||||
.on('reconnecting', function reconnecting(opts) {
|
.on('reconnecting', function reconnecting(opts) {
|
||||||
console.warn('We are scheduling a reconnect operation', opts);
|
console.warn('We are scheduling a reconnect operation', opts);
|
||||||
})
|
})
|
||||||
|
.on('node-pong', function(data) {
|
||||||
|
var latency = (new Date()).getTime() - self._latency;
|
||||||
|
socket.emit('latency', { id: self.id, latency: latency });
|
||||||
|
})
|
||||||
.on('data', function incoming(data) {
|
.on('data', function incoming(data) {
|
||||||
console.info('Received some data', data);
|
console.info('Received some data', data);
|
||||||
});
|
});
|
||||||
@ -364,7 +369,8 @@ Node.prototype.update = function()
|
|||||||
|
|
||||||
Node.prototype.ping = function()
|
Node.prototype.ping = function()
|
||||||
{
|
{
|
||||||
this.emit('node-ping', '');
|
this._latency = (new Date()).getTime();
|
||||||
|
this.emit('node-ping', { id: this.id });
|
||||||
};
|
};
|
||||||
|
|
||||||
Node.prototype.setWatches = function()
|
Node.prototype.setWatches = function()
|
||||||
|
Loading…
Reference in New Issue
Block a user