Add FlushConsolidationHandler

This commit is contained in:
s809
2024-04-16 20:32:50 +05:00
parent 5f9f0f23b8
commit 7c33dda11b
@@ -27,6 +27,7 @@ import io.netty.channel.*;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import io.netty.handler.codec.LengthFieldPrepender;
import io.netty.handler.flush.FlushConsolidationHandler;
import org.jetbrains.annotations.NotNull;
/** Used when creating a network channel */
@@ -48,6 +49,7 @@ public class NettyChannelInitializer extends ChannelInitializer<SocketChannel>
ChannelPipeline pipeline = socketChannel.pipeline();
// Encoder
pipeline.addLast(new FlushConsolidationHandler(FlushConsolidationHandler.DEFAULT_EXPLICIT_FLUSH_AFTER_FLUSHES, true));
pipeline.addLast(new LengthFieldPrepender(Integer.BYTES));
pipeline.addLast(new MessageEncoder<>(NettyMessageRegistry.INSTANCE, NettyMessage.class));
pipeline.addLast(new NettyOutboundExceptionRouter());