[测评系统]--测评系统核心代码库
林致杰
2022-07-29 f315f2f94d7dab7e1b90f8c70b2dc324c594680c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package com.ots.project.tool.report.reportCalculation.socket.netty;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;
public class NettyClientInitializer extends ChannelInitializer<SocketChannel> {
    private NettyClient nettyClient;
    public NettyClientInitializer(NettyClient nettyClient) {
        this.nettyClient = nettyClient;
    }
    protected void initChannel(SocketChannel ch) {
        ChannelPipeline pipeline = ch.pipeline();
 
 
 
        
        pipeline.addLast("decoder", new StringDecoder());
        pipeline.addLast("encoder", new StringEncoder());
        
        pipeline.addLast(new NettyClientHandler(nettyClient));
    }
}