mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-29 22:23:21 -04:00
send keepalive packet. closes #9
This commit is contained in:
parent
39bb59d288
commit
0f9bc0498e
16
test.js
16
test.js
@ -75,13 +75,20 @@ function getLoginSession(cb) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var packetHandlers = {
|
var packetHandlers = {
|
||||||
|
0x00: onKeepAlive,
|
||||||
|
0x01: onLoginRequest,
|
||||||
|
0x03: onChatMessage,
|
||||||
0xFC: onEncryptionKeyResponse,
|
0xFC: onEncryptionKeyResponse,
|
||||||
0xFD: onEncryptionKeyRequest,
|
0xFD: onEncryptionKeyRequest,
|
||||||
0x01: onLoginRequest,
|
|
||||||
0xFF: onKick,
|
0xFF: onKick,
|
||||||
0x03: onChatMessage,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function onKeepAlive(packet) {
|
||||||
|
parser.writePacket(Parser.KEEP_ALIVE, {
|
||||||
|
keepAliveId: packet.keepAliveId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function onKick(packet) {
|
function onKick(packet) {
|
||||||
console.log("kick", packet);
|
console.log("kick", packet);
|
||||||
}
|
}
|
||||||
@ -92,6 +99,11 @@ function onLoginRequest(packet) {
|
|||||||
|
|
||||||
function onChatMessage(packet) {
|
function onChatMessage(packet) {
|
||||||
console.log("chat message", packet);
|
console.log("chat message", packet);
|
||||||
|
if (packet.message.indexOf(loginSession.username) === -1) {
|
||||||
|
parser.writePacket(Parser.CHAT_MESSAGE, {
|
||||||
|
message: packet.message,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onEncryptionKeyRequest(packet) {
|
function onEncryptionKeyRequest(packet) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user