mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-27 13:14:41 -04:00
Add latency measurement to lib/ping.js
This commit is contained in:
parent
77e84b15fc
commit
e8e78e2942
@ -19,6 +19,7 @@ function ping(options, cb) {
|
||||
motd: parts[3],
|
||||
playerCount: parseInt(parts[4], 10),
|
||||
maxPlayers: parseInt(parts[5], 10),
|
||||
latency: Date.now() - start
|
||||
};
|
||||
} catch (err) {
|
||||
client.end();
|
||||
@ -34,5 +35,7 @@ function ping(options, cb) {
|
||||
client.on('connect', function() {
|
||||
client.write(0xfe, { magic: 1 });
|
||||
});
|
||||
|
||||
var start = Date.now();
|
||||
client.connect(port, host);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user