use of com.code.server.gate.handle.GameMsgHandler in project summer by foxsugar.
the class SocketServerInitializer method initChannel.
@Override
public void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline p = ch.pipeline();
if (sslCtx != null) {
p.addLast(sslCtx.newHandler(ch.alloc()));
}
// p.addLast(new LoggingHandler(LogLevel.INFO));
p.addLast("encoder", new GameCharsEncoder());
p.addLast("decoder", new GameCharsDecoder());
p.addLast("timeout", new IdleStateHandler(15, 0, 0, TimeUnit.SECONDS));
// p.addLast(new SocketHandler());
p.addLast("gameHandler", new GameMsgHandler());
}
use of com.code.server.gate.handle.GameMsgHandler in project summer by foxsugar.
the class WebSocketServerInitializer method initChannel.
@Override
protected void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
// 处理日志
// pipeline.addLast(new LoggingHandler(LogLevel.INFO));
// 处理心跳
// pipeline.addLast(new IdleStateHandler(15, 0, 0, TimeUnit.SECONDS));
// pipeline.addLast(new ChatHeartbeatHandler());
// // 获取职责链
// pipeline.addLast("http-codec", new HttpServerCodec());
// pipeline.addLast("aggregator", new HttpObjectAggregator(64*1024));
// pipeline.addLast("http-chunked", new ChunkedWriteHandler());
// // pipeline.addLast(new WebSocketServerCompressionHandler());
//
// // pipeline.addLast("encoder", new WsEncoder());
// // pipeline.addLast("decoder", new WsDecoder());
// pipeline.addLast("handshake",new WebSocketServerProtocolHandler("/ws"));
// pipeline.addLast(new WsCodec());
// // pipeline.addLast(new WsGameMsgHandler());
// pipeline.addLast(new WsHandler());
// // pipeline.addLast("codec", new WsEncoder());
// //websocket定义了传递数据的6中frame类型
// // pipeline.addLast(new GameMsgHandler());
//
pipeline.addLast(new HttpServerCodec());
pipeline.addLast(new HttpObjectAggregator(64 * 1024));
pipeline.addLast(new WebSocketServerProtocolHandler("/websocket", null, true));
pipeline.addLast(new WsCodec());
pipeline.addLast(new GameMsgHandler());
// ChannelPipeline pipeline = ch.pipeline();
// pipeline.addLast(new HttpServerCodec());
// pipeline.addLast(new HttpObjectAggregator(65536));
// // pipeline.addLast(new WebSocketServerCompressionHandler());
// // pipeline.addLast(new WebSocketServerProtocolHandler(WEBSOCKET_PATH, null, true));
// // pipeline.addLast(new WebSocketIndexPageHandler(WEBSOCKET_PATH));
// pipeline.addLast(new WebSocketServerHandler());
}
Aggregations