Quick clean up
This commit is contained in:
parent
97aecdcc09
commit
1c1f49aa43
2
app.js
2
app.js
@ -17,8 +17,6 @@ function pingAll() {
|
||||
// Handle our ping results, if it succeeded.
|
||||
if (err) {
|
||||
logger.log('error', 'Failed to ping ' + network.ip + ': ' + err);
|
||||
} else {
|
||||
console.log(network.ip + ': ' + res.players.online);
|
||||
}
|
||||
|
||||
server.io.sockets.emit('update', res);
|
||||
|
@ -5,6 +5,7 @@ winston.remove(winston.transports.Console);
|
||||
winston.add(winston.transports.File, {
|
||||
filename: 'minetrack.log'
|
||||
});
|
||||
|
||||
winston.add(winston.transports.Console, {
|
||||
'timestamp': function() {
|
||||
var date = new Date();
|
||||
|
19
lib/ping.js
19
lib/ping.js
@ -88,6 +88,16 @@ function pingMinecraftPC(host, port, timeout, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
// Wraps our Buffer into another to fit the Minecraft protocol.
|
||||
function writePCBuffer(client, buffer) {
|
||||
var length = mcpc.createBuffer();
|
||||
|
||||
length.writeVarInt(buffer.buffer().length);
|
||||
|
||||
client.write(Buffer.concat([length.buffer(), buffer.buffer()]));
|
||||
}
|
||||
|
||||
// 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();
|
||||
|
||||
@ -108,15 +118,6 @@ function pingMinecraftPE(host, port, timeout, callback) {
|
||||
}, timeout);
|
||||
}
|
||||
|
||||
// Wraps our Buffer into another to fit the Minecraft protocol.
|
||||
function writePCBuffer(client, buffer) {
|
||||
var length = mcpc.createBuffer();
|
||||
|
||||
length.writeVarInt(buffer.buffer().length);
|
||||
|
||||
client.write(Buffer.concat([length.buffer(), buffer.buffer()]));
|
||||
}
|
||||
|
||||
exports.ping = function(host, port, type, timeout, callback) {
|
||||
if (type === 'PC') {
|
||||
pingMinecraftPC(host, port || 25565, timeout, callback);
|
||||
|
Loading…
Reference in New Issue
Block a user