Begin work on frontend!
This commit is contained in:
15
lib/ping.js
15
lib/ping.js
@ -1,11 +1,11 @@
|
||||
var mcpe_ping = require('mcpe-ping');
|
||||
var mcpc_ping = require('mc-ping-updated');
|
||||
|
||||
var profiler = require('./profiler');
|
||||
var util = require('./util');
|
||||
|
||||
// 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) {
|
||||
profiler.track(host);
|
||||
var startTime = util.getCurrentTimeMs();
|
||||
|
||||
// Try catch incase the down stream module is bad at handling exceptions.
|
||||
try {
|
||||
@ -20,7 +20,8 @@ function pingMinecraftPC(host, port, timeout, callback) {
|
||||
max: res.players.max
|
||||
},
|
||||
version: res.version.protocol,
|
||||
latency: profiler.untrack(host)
|
||||
latency: util.getCurrentTimeMs() - startTime,
|
||||
favicon: res.favicon
|
||||
});
|
||||
}
|
||||
}, timeout);
|
||||
@ -31,7 +32,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) {
|
||||
profiler.track(host);
|
||||
var startTime = util.getCurrentTimeMs();
|
||||
|
||||
// Try catch incase the down stream module is bad at handling exceptions.
|
||||
try {
|
||||
@ -42,11 +43,11 @@ function pingMinecraftPE(host, port, timeout, callback) {
|
||||
// Remap our JSON into our custom structure.
|
||||
callback(err, {
|
||||
players: {
|
||||
online: res.currentPlayers,
|
||||
max: res.maxPlayers
|
||||
online: parseInt(res.currentPlayers),
|
||||
max: parseInt(res.maxPlayers)
|
||||
},
|
||||
version: res.version,
|
||||
latency: profiler.untrack(host)
|
||||
latency: util.getCurrentTimeMs() - startTime
|
||||
});
|
||||
}
|
||||
}, timeout);
|
||||
|
Reference in New Issue
Block a user