fixed bug

This commit is contained in:
cubedro 2015-06-02 05:06:53 +03:00
parent 11cc9897fb
commit e92b68673e

6
app.js
View File

@ -209,7 +209,7 @@ api.on('connection', function(spark) {
askedForHistory = false; askedForHistory = false;
}); });
spark.on('node-ping', function(data) spark.on('node-ping', function (data)
{ {
var start = (!_.isUndefined(data) && !_.isUndefined(data.clientTime) ? data.clientTime : null); var start = (!_.isUndefined(data) && !_.isUndefined(data.clientTime) ? data.clientTime : null);
@ -219,7 +219,7 @@ api.on('connection', function(spark) {
}); });
}); });
spark.on('latency', function(data) spark.on('latency', function (data)
{ {
if( !_.isUndefined(data.id) ) if( !_.isUndefined(data.id) )
{ {
@ -270,7 +270,7 @@ client.on('connection', function (clientSpark)
clientSpark.on('client-pong', function (data) clientSpark.on('client-pong', function (data)
{ {
var start = (!_.isUndefined(data) && !_.isUndefined(data.serverTime) ? data.serverTime : clientLatency); var start = (!_.isUndefined(data) && !_.isUndefined(data.serverTime) ? data.serverTime : clientLatency);
var latency = Math.ceil( (_.now() - data.serverTime) / 2 ); var latency = Math.ceil( (_.now() - start) / 2 );
clientSpark.emit('client-latency', { latency: latency }); clientSpark.emit('client-latency', { latency: latency });
}); });