mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-29 14:13:45 -04:00
Allow beforePing to receive a callback to call with its result when
it accepts three arguements. Allows async processing while calculating response.
This commit is contained in:
parent
df2caf74cb
commit
16452d4a4c
@ -100,15 +100,25 @@ function createServer(options) {
|
||||
"favicon": server.favicon
|
||||
};
|
||||
|
||||
function answerToPing(err, response) {
|
||||
if ( err ) return;
|
||||
client.write('server_info', {response: JSON.stringify(response)});
|
||||
}
|
||||
|
||||
if(beforePing) {
|
||||
response = beforePing(response, client) || response;
|
||||
if ( beforePing.length > 2 ) {
|
||||
beforePing(response, client, answerToPing);
|
||||
} else {
|
||||
answerToPing(null, beforePing(response, client) || response);
|
||||
}
|
||||
} else {
|
||||
answerToPing(null, response);
|
||||
}
|
||||
|
||||
client.once('ping', function(packet) {
|
||||
client.write('ping', {time: packet.time});
|
||||
client.end();
|
||||
});
|
||||
client.write('server_info', {response: JSON.stringify(response)});
|
||||
}
|
||||
|
||||
function onLogin(packet) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user