Search in sources :

Example 1 with PacketCompressor

use of com.github.dirtpowered.dirtmv.network.server.codec.netty.PacketCompressor 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());
}
Also used : PacketCompressor(com.github.dirtpowered.dirtmv.network.server.codec.netty.PacketCompressor) PacketDecompressor(com.github.dirtpowered.dirtmv.network.server.codec.netty.PacketDecompressor) PacketData(com.github.dirtpowered.dirtmv.data.protocol.PacketData)

Aggregations

PacketData (com.github.dirtpowered.dirtmv.data.protocol.PacketData)1 PacketCompressor (com.github.dirtpowered.dirtmv.network.server.codec.netty.PacketCompressor)1 PacketDecompressor (com.github.dirtpowered.dirtmv.network.server.codec.netty.PacketDecompressor)1