From e92b68673e0a1fbf7aec459e35f121f808092a1b Mon Sep 17 00:00:00 2001 From: cubedro Date: Tue, 2 Jun 2015 05:06:53 +0300 Subject: [PATCH] fixed bug --- app.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index 04bc6b4..89baea8 100644 --- a/app.js +++ b/app.js @@ -209,7 +209,7 @@ api.on('connection', function(spark) { askedForHistory = false; }); - spark.on('node-ping', function(data) + spark.on('node-ping', function (data) { 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) ) { @@ -270,7 +270,7 @@ client.on('connection', function (clientSpark) clientSpark.on('client-pong', function (data) { 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 }); });