lmw
2023-05-27 ff365ff4346d220edf2ec1d0041f2284befe3870
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));
    }
}