Add listener for compression request

This commit is contained in:
Will Franzen 2014-12-30 02:15:08 -06:00
parent cfa30d9e1d
commit b73884e236

View file

@ -141,6 +141,8 @@ function createServer(options) {
hash = crypto.createHash("sha1"); hash = crypto.createHash("sha1");
hash.update(serverId); hash.update(serverId);
client.once([states.LOGIN, 0x01], onEncryptionKeyResponse); client.once([states.LOGIN, 0x01], onEncryptionKeyResponse);
client.once([states.LOGIN, 0x03], onCompressionRequest);
client.on( [states.PLAY, 0x46], onCompressionRequest);
client.write(0x01, { client.write(0x01, {
serverId: serverId, serverId: serverId,
publicKey: client.publicKey, publicKey: client.publicKey,
@ -193,6 +195,10 @@ function createServer(options) {
} }
} }
function onCompressionRequest(packet) {
client.compressionThreshold = packet.threshold;
}
function loginClient() { function loginClient() {
var isException = !!server.onlineModeExceptions[client.username.toLowerCase()]; var isException = !!server.onlineModeExceptions[client.username.toLowerCase()];
if (onlineMode == false || isException) { if (onlineMode == false || isException) {