UNPKG

watchmen-ping-mc2

Version:

Watchmen Minecraft server pinger

31 lines (26 loc) 992 B
const mcping = require('mc-ping-updated'); function PingService(){} exports = module.exports = PingService; PingService.prototype.ping = function(service, callback){ var startTime = +new Date(); mcping(service.url, service.port, function(err, res) { if (err) { // Some kind of error console.error(err); return callback(err, res, 500, +new Date() - startTime); } else { // Success! //console.log(res); //var endTime = +new Date(); //console.log(); //console.log(" URL = " + service.url + " : " + service.port); //console.log(" Max Players = " + JSON.stringify(res.players.max, null, 2)); console.log(" Online Players = " + JSON.stringify(res.players.online, null, 2)); //console.log(" ok" + (endTime - startTime) + " ms"); return callback(null, res, 200, +new Date() - startTime); } }, 3000); }; PingService.prototype.getDefaultOptions = function(){ return {}; // there is not need for UI confi options for this ping service }