fixed client latency

pull/5/head
cubedro 10 years ago
parent 69a619804d
commit b9a9321cac
  1. 5
      app.js

@ -267,6 +267,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 );
clientSpark.emit('client-latency', { latency: latency });
@ -275,10 +276,12 @@ client.on('connection', function (clientSpark)
var latencyTimeout = setInterval( function ()
{
clientLatency = _.now();
client.write({
action: 'client-ping',
data: {
serverTime: _.now()
serverTime: clientLatency
}
});
}, 5000);

Loading…
Cancel
Save