mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-29 06:03:33 -04:00
Update examples to log when connection is lost
Normally, the client will send a kick packet if the client is disconnected from the server, but if the connection is lost due to network or lower-level protocol issues, the 'end' event will be emitted. Log this event in the examples so it is clear why the scripts exit.
This commit is contained in:
parent
46a134c5e9
commit
1349fdfc73
@ -18,6 +18,9 @@ client.on('connect', function() {
|
||||
client.on('disconnect', function(packet) {
|
||||
console.log('disconnected: '+ packet.reason);
|
||||
});
|
||||
client.on('end', function(err) {
|
||||
console.log('Connection lost');
|
||||
});
|
||||
client.on('chat', function(packet) {
|
||||
var jsonMsg = JSON.parse(packet.message);
|
||||
if(jsonMsg.translate == 'chat.type.announcement' || jsonMsg.translate == 'chat.type.text') {
|
||||
|
@ -20,6 +20,9 @@ client.on('connect', function() {
|
||||
client.on('disconnect', function(packet) {
|
||||
console.log('disconnected: '+ packet.reason);
|
||||
});
|
||||
client.on('end', function(err) {
|
||||
console.log('Connection lost');
|
||||
});
|
||||
client.on('chat', function(packet) {
|
||||
var jsonMsg = JSON.parse(packet.message);
|
||||
if(jsonMsg.translate == 'chat.type.announcement' || jsonMsg.translate == 'chat.type.text') {
|
||||
|
Loading…
x
Reference in New Issue
Block a user