protected void initChannel(NioSocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
// 编解码 http 请求
pipeline.addLast(new HttpServerCodec());
// 写文件内容
pipeline.addLast(new ChunkedWriteHandler());
// 聚合解码 HttpRequest/HttpContent/LastHttpContent 到 FullHttpRequest
// 保证接收的 Http 请求的完整性
pipeline.addLast(new HttpObjectAggregator(64 * 1024));
// 处理其他的 WebSocketFrame
pipeline.addLast(new WebSocketServerProtocolHandler("/chat"));
// 处理 TextWebSocketFrame
pipeline.addLast(protoCodec);
pipeline.addLast(serverHandler);
}
WebSocketServerInitializer.java 文件源码
java
阅读 56
收藏 0
点赞 0
评论 0
项目:os
作者:
评论列表
文章目录