Search in sources :

Example 1 with HelloWordServerHandler

use of org.ko.netty.t3.handler.HelloWordServerHandler in project tutorials-java by Artister.

the class ServerChannelInitializer method initChannel.

@Override
protected void initChannel(SocketChannel socketChannel) throws Exception {
    ChannelPipeline pipeline = socketChannel.pipeline();
    // 字符串解码 和 编码
    pipeline.addLast("decoder", new StringDecoder());
    pipeline.addLast("encoder", new StringEncoder());
    // 字符长度
    pipeline.addLast(new LineBasedFrameDecoder(2048));
    // 自己的逻辑Handler
    pipeline.addLast("handler", new HelloWordServerHandler());
}
Also used : StringEncoder(io.netty.handler.codec.string.StringEncoder) HelloWordServerHandler(org.ko.netty.t3.handler.HelloWordServerHandler) StringDecoder(io.netty.handler.codec.string.StringDecoder) LineBasedFrameDecoder(io.netty.handler.codec.LineBasedFrameDecoder) ChannelPipeline(io.netty.channel.ChannelPipeline)

Aggregations

ChannelPipeline (io.netty.channel.ChannelPipeline)1 LineBasedFrameDecoder (io.netty.handler.codec.LineBasedFrameDecoder)1 StringDecoder (io.netty.handler.codec.string.StringDecoder)1 StringEncoder (io.netty.handler.codec.string.StringEncoder)1 HelloWordServerHandler (org.ko.netty.t3.handler.HelloWordServerHandler)1