Use a basic time tracker instead of Date manipulation

This commit is contained in:
Cryptkeeper
2015-11-03 01:40:09 -06:00
parent fcff7a0fec
commit 3373ebc9ee
4 changed files with 49 additions and 14 deletions

View File

@ -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);