mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-28 13:45:37 -04:00
Added client.latency
This commit is contained in:
parent
3cc3fd7a7e
commit
1ffdd8bd4f
@ -50,6 +50,8 @@ function createServer(options) {
|
|||||||
var loginKickTimer = setTimeout(kickForNotLoggingIn, kickTimeout);
|
var loginKickTimer = setTimeout(kickForNotLoggingIn, kickTimeout);
|
||||||
|
|
||||||
var serverId;
|
var serverId;
|
||||||
|
|
||||||
|
var sendKeepAliveTime;
|
||||||
|
|
||||||
function kickForNotLoggingIn() {
|
function kickForNotLoggingIn() {
|
||||||
client.end('LoginTimeout');
|
client.end('LoginTimeout');
|
||||||
@ -65,12 +67,14 @@ function createServer(options) {
|
|||||||
client.end('KeepAliveTimeout');
|
client.end('KeepAliveTimeout');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
sendKeepAliveTime = new Date();
|
||||||
client.write('keep_alive', {
|
client.write('keep_alive', {
|
||||||
keepAliveId: Math.floor(Math.random() * 2147483648)
|
keepAliveId: Math.floor(Math.random() * 2147483648)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function onKeepAlive() {
|
function onKeepAlive() {
|
||||||
|
client.latency = (new Date()) - sendKeepAliveTime;
|
||||||
lastKeepAlive = new Date();
|
lastKeepAlive = new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user