Merge pull request #311 from netraameht/master

Added client.latency
This commit is contained in:
Romain Beaumont 2015-12-22 00:04:39 +01:00
commit 3b4cd6ef6a

View File

@ -51,6 +51,8 @@ function createServer(options) {
var serverId;
var sendKeepAliveTime;
function kickForNotLoggingIn() {
client.end('LoginTimeout');
}
@ -65,12 +67,14 @@ function createServer(options) {
client.end('KeepAliveTimeout');
return;
}
sendKeepAliveTime = new Date();
client.write('keep_alive', {
keepAliveId: Math.floor(Math.random() * 2147483648)
});
}
function onKeepAlive() {
client.latency = (new Date()) - sendKeepAliveTime;
lastKeepAlive = new Date();
}