Quick clean up

This commit is contained in:
Cryptkeeper 2015-11-02 01:04:49 -06:00
parent 97aecdcc09
commit 1c1f49aa43
3 changed files with 11 additions and 11 deletions

2
app.js

@ -17,8 +17,6 @@ function pingAll() {
// Handle our ping results, if it succeeded. // Handle our ping results, if it succeeded.
if (err) { if (err) {
logger.log('error', 'Failed to ping ' + network.ip + ': ' + err); logger.log('error', 'Failed to ping ' + network.ip + ': ' + err);
} else {
console.log(network.ip + ': ' + res.players.online);
} }
server.io.sockets.emit('update', res); server.io.sockets.emit('update', res);

@ -5,6 +5,7 @@ winston.remove(winston.transports.Console);
winston.add(winston.transports.File, { winston.add(winston.transports.File, {
filename: 'minetrack.log' filename: 'minetrack.log'
}); });
winston.add(winston.transports.Console, { winston.add(winston.transports.Console, {
'timestamp': function() { 'timestamp': function() {
var date = new Date(); var date = new Date();

@ -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) { function pingMinecraftPE(host, port, timeout, callback) {
var milliseconds = (new Date).getTime(); var milliseconds = (new Date).getTime();
@ -108,15 +118,6 @@ function pingMinecraftPE(host, port, timeout, callback) {
}, timeout); }, 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) { exports.ping = function(host, port, type, timeout, callback) {
if (type === 'PC') { if (type === 'PC') {
pingMinecraftPC(host, port || 25565, timeout, callback); pingMinecraftPC(host, port || 25565, timeout, callback);