use of com.github.dirtpowered.dirtmv.network.server.codec.netty.PacketDecompressor in project DirtMultiversion by DirtPowered.
the class ProtocolRelease47To5 method enableCompression.
private void enableCompression(ServerSession session) {
int threshold = session.getMain().getConfiguration().getCompressionThreshold();
if (threshold < 0) {
Logger.info("packet compression is disabled");
return;
}
PacketData compressionPacket = PacketUtil.createPacket(0x03, new TypeHolder[] { set(Type.VAR_INT, threshold) });
session.sendPacket(compressionPacket, PacketDirection.TO_CLIENT, getFrom());
// add compression handlers to pipeline
session.getChannel().pipeline().addAfter(ChannelConstants.NETTY_LENGTH_ENCODER, ChannelConstants.PACKET_COMPRESSION, new PacketCompressor(threshold)).addAfter(ChannelConstants.NETTY_LENGTH_DECODER, ChannelConstants.PACKET_DECOMPRESSION, new PacketDecompressor());
}
Aggregations