added latency update
This commit is contained in:
parent
447afd00d5
commit
2ce486db28
@ -82,6 +82,7 @@ function Node()
|
||||
this._tries = 0;
|
||||
this._down = 0;
|
||||
this._lastSent = 0;
|
||||
this._latency = 0;
|
||||
|
||||
this.blocks = [];
|
||||
|
||||
@ -106,6 +107,10 @@ function Node()
|
||||
.on('reconnecting', function reconnecting(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) {
|
||||
console.info('Received some data', data);
|
||||
});
|
||||
@ -364,6 +369,7 @@ Node.prototype.update = function()
|
||||
|
||||
Node.prototype.ping = function()
|
||||
{
|
||||
this._latency = (new Date()).getTime();
|
||||
this.emit('node-ping', { id: this.id });
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user