Search in sources :

Example 1 with GameMsgHandler

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());
}
Also used : GameCharsDecoder(com.code.server.gate.encoding.GameCharsDecoder) GameMsgHandler(com.code.server.gate.handle.GameMsgHandler) IdleStateHandler(io.netty.handler.timeout.IdleStateHandler) GameCharsEncoder(com.code.server.gate.encoding.GameCharsEncoder) ChannelPipeline(io.netty.channel.ChannelPipeline)

Example 2 with 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());
}
Also used : HttpObjectAggregator(io.netty.handler.codec.http.HttpObjectAggregator) GameMsgHandler(com.code.server.gate.handle.GameMsgHandler) WsCodec(com.code.server.gate.encoding.WsCodec) HttpServerCodec(io.netty.handler.codec.http.HttpServerCodec) WebSocketServerProtocolHandler(io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler) ChannelPipeline(io.netty.channel.ChannelPipeline)

Aggregations

GameMsgHandler (com.code.server.gate.handle.GameMsgHandler)2 ChannelPipeline (io.netty.channel.ChannelPipeline)2 GameCharsDecoder (com.code.server.gate.encoding.GameCharsDecoder)1 GameCharsEncoder (com.code.server.gate.encoding.GameCharsEncoder)1 WsCodec (com.code.server.gate.encoding.WsCodec)1 HttpObjectAggregator (io.netty.handler.codec.http.HttpObjectAggregator)1 HttpServerCodec (io.netty.handler.codec.http.HttpServerCodec)1 WebSocketServerProtocolHandler (io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler)1 IdleStateHandler (io.netty.handler.timeout.IdleStateHandler)1