mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-11-15 03:14:56 -05:00
send keepalive packet. closes #9
This commit is contained in:
parent
39bb59d288
commit
0f9bc0498e
1 changed files with 14 additions and 2 deletions
16
test.js
16
test.js
|
@ -75,13 +75,20 @@ function getLoginSession(cb) {
|
|||
}
|
||||
|
||||
var packetHandlers = {
|
||||
0x00: onKeepAlive,
|
||||
0x01: onLoginRequest,
|
||||
0x03: onChatMessage,
|
||||
0xFC: onEncryptionKeyResponse,
|
||||
0xFD: onEncryptionKeyRequest,
|
||||
0x01: onLoginRequest,
|
||||
0xFF: onKick,
|
||||
0x03: onChatMessage,
|
||||
};
|
||||
|
||||
function onKeepAlive(packet) {
|
||||
parser.writePacket(Parser.KEEP_ALIVE, {
|
||||
keepAliveId: packet.keepAliveId
|
||||
});
|
||||
}
|
||||
|
||||
function onKick(packet) {
|
||||
console.log("kick", packet);
|
||||
}
|
||||
|
@ -92,6 +99,11 @@ function onLoginRequest(packet) {
|
|||
|
||||
function onChatMessage(packet) {
|
||||
console.log("chat message", packet);
|
||||
if (packet.message.indexOf(loginSession.username) === -1) {
|
||||
parser.writePacket(Parser.CHAT_MESSAGE, {
|
||||
message: packet.message,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function onEncryptionKeyRequest(packet) {
|
||||
|
|
Loading…
Reference in a new issue