send keepalive packet. closes #9

This commit is contained in:
Andrew Kelley 2013-01-01 16:08:08 -05:00
parent 39bb59d288
commit 0f9bc0498e

16
test.js
View file

@ -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) {