From b73884e2365ea444bc57fd5f62821760352d8c87 Mon Sep 17 00:00:00 2001 From: Will Franzen Date: Tue, 30 Dec 2014 02:15:08 -0600 Subject: [PATCH] Add listener for compression request --- index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/index.js b/index.js index 5e117d7..a63a88c 100644 --- a/index.js +++ b/index.js @@ -141,6 +141,8 @@ function createServer(options) { hash = crypto.createHash("sha1"); hash.update(serverId); client.once([states.LOGIN, 0x01], onEncryptionKeyResponse); + client.once([states.LOGIN, 0x03], onCompressionRequest); + client.on( [states.PLAY, 0x46], onCompressionRequest); client.write(0x01, { serverId: serverId, publicKey: client.publicKey, @@ -193,6 +195,10 @@ function createServer(options) { } } + function onCompressionRequest(packet) { + client.compressionThreshold = packet.threshold; + } + function loginClient() { var isException = !!server.onlineModeExceptions[client.username.toLowerCase()]; if (onlineMode == false || isException) {