Use a basic time tracker instead of Date manipulation
This commit is contained in:
10
lib/ping.js
10
lib/ping.js
@ -1,9 +1,11 @@
|
||||
var mcpe_ping = require('mcpe-ping');
|
||||
var mcpc_ping = require('mc-ping-updated');
|
||||
|
||||
var profiler = require('./profiler');
|
||||
|
||||
// This is a wrapper function for mc-ping-updated, mainly used to convert the data structure of the result.
|
||||
function pingMinecraftPC(host, port, timeout, callback) {
|
||||
var milliseconds = (new Date).getTime();
|
||||
profiler.track(host);
|
||||
|
||||
// Try catch incase the down stream module is bad at handling exceptions.
|
||||
try {
|
||||
@ -18,7 +20,7 @@ function pingMinecraftPC(host, port, timeout, callback) {
|
||||
max: res.players.max
|
||||
},
|
||||
version: res.version.protocol,
|
||||
latency: (new Date).getTime() - milliseconds
|
||||
latency: profiler.untrack(host)
|
||||
});
|
||||
}
|
||||
}, timeout);
|
||||
@ -29,7 +31,7 @@ function pingMinecraftPC(host, port, timeout, callback) {
|
||||
|
||||
// This is a wrapper function for mcpe-ping, mainly used to convert the data structure of the result.
|
||||
function pingMinecraftPE(host, port, timeout, callback) {
|
||||
var milliseconds = (new Date).getTime();
|
||||
profiler.track(host);
|
||||
|
||||
// Try catch incase the down stream module is bad at handling exceptions.
|
||||
try {
|
||||
@ -44,7 +46,7 @@ function pingMinecraftPE(host, port, timeout, callback) {
|
||||
max: res.maxPlayers
|
||||
},
|
||||
version: res.version,
|
||||
latency: (new Date).getTime() - milliseconds
|
||||
latency: profiler.untrack(host)
|
||||
});
|
||||
}
|
||||
}, timeout);
|
||||
|
Reference in New Issue
Block a user