netty
如何使用
package demo1;
import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;
import io.netty.handler.codec.http2.Http2ChannelDuplexHandler;
/**
* @Author: small_double
* @Date: 2019/10/2 上午11:01
*/
public class TestServerInitializer extends ChannelInitializer<SocketChannel> {
@Override
protected void initChannel(SocketChannel socketChannel) throws Exception {
ChannelPipeline channelPipeline = socketChannel.pipeline();
channelPipeline.addLast("httpServerCodec",new HttpServerCodec());
channelPipeline.addLast("testServerHandler", new TestServerHandler());
}
}原理极其源码笔记
Last updated
Was this helpful?