lmw
2023-06-13 4b7d8d9a038f6522df46d0f14fa07eb940a1b34d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package cn.sinata.rxnetty.pipeline;
 
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import io.netty.handler.codec.LengthFieldPrepender;
import io.reactivex.netty.pipeline.PipelineConfigurator;
 
public class LengthFieldConfigurator implements PipelineConfigurator<ByteBuf,ByteBuf> {
 
    @Override
    public void configureNewPipeline(ChannelPipeline pipeline) {
        pipeline.addLast("decoder", new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 0, 4, 0, 4));
        pipeline.addLast("encoder", new LengthFieldPrepender(4));
    }
}