Drop the try catches, this might make it a bit unstable until we work out some bugs.

This commit is contained in:
Cryptkeeper 2015-11-25 19:29:00 -06:00
parent 0150e3b30e
commit 82752767b9

@ -7,53 +7,43 @@ var util = require('./util');
function pingMinecraftPC(host, port, timeout, callback) { function pingMinecraftPC(host, port, timeout, callback) {
var startTime = util.getCurrentTimeMs(); var startTime = util.getCurrentTimeMs();
// Try catch incase the down stream module is bad at handling exceptions. mcpc_ping(host, port, function(err, res) {
try { if (err) {
mcpc_ping(host, port, function(err, res) { callback(err, null);
if (err) { } else {
callback(err, null); // Remap our JSON into our custom structure.
} else { callback(null, {
// Remap our JSON into our custom structure. players: {
callback(null, { online: res.players.online,
players: { max: res.players.max
online: res.players.online, },
max: res.players.max version: res.version.protocol,
}, latency: util.getCurrentTimeMs() - startTime,
version: res.version.protocol, favicon: res.favicon
latency: util.getCurrentTimeMs() - startTime, });
favicon: res.favicon }
}); }, timeout);
}
}, timeout);
} catch (err) {
callback(err, null);
}
} }
// This is a wrapper function for mcpe-ping, mainly used to convert the data structure of the result. // This is a wrapper function for mcpe-ping, mainly used to convert the data structure of the result.
function pingMinecraftPE(host, port, timeout, callback) { function pingMinecraftPE(host, port, timeout, callback) {
var startTime = util.getCurrentTimeMs(); var startTime = util.getCurrentTimeMs();
// Try catch incase the down stream module is bad at handling exceptions. mcpe_ping(host, port || 19132, function(err, res) {
try { if (err) {
mcpe_ping(host, port || 19132, function(err, res) { callback(err, null);
if (err) { } else {
callback(err, null); // Remap our JSON into our custom structure.
} else { callback(err, {
// Remap our JSON into our custom structure. players: {
callback(err, { online: parseInt(res.currentPlayers),
players: { max: parseInt(res.maxPlayers)
online: parseInt(res.currentPlayers), },
max: parseInt(res.maxPlayers) version: res.version,
}, latency: util.getCurrentTimeMs() - startTime
version: res.version, });
latency: util.getCurrentTimeMs() - startTime }
}); }, timeout);
}
}, timeout);
} catch (err) {
callback(err, null);
}
} }
exports.ping = function(host, port, type, timeout, callback) { exports.ping = function(host, port, type, timeout, callback) {