ChatServerInitializer.java 文件源码

java
阅读 36 收藏 0 点赞 0 评论 0

项目:study-netty 作者:
@Override
protected void initChannel(Channel ch) throws Exception {
    ChannelPipeline pipeline = ch.pipeline();
    //编解码http请求
    pipeline.addLast(new HttpServerCodec());
    //聚合解码HttpRequest/HttpContent/LastHttpContent到FullHttpRequest
    //保证接收的Http请求的完整性
    pipeline.addLast(new HttpObjectAggregator(64 *1024));
    //写文件内容
    pipeline.addLast(new ChunkedWriteHandler());
    //处理FullHttpRequest
    pipeline.addLast(new HttpRequestHandler("/ws"));
    //处理其他的WebSocketFrame
    pipeline.addLast(new WebSocketServerProtocolHandler("/ws"));
    //处理TextWebSocketFrame
    pipeline.addLast(new TextWebSocketFrameHandler(group));
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号