Search in sources :

Example 1 with WsCodec

use of com.code.server.gate.encoding.WsCodec 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

WsCodec (com.code.server.gate.encoding.WsCodec)1 GameMsgHandler (com.code.server.gate.handle.GameMsgHandler)1 ChannelPipeline (io.netty.channel.ChannelPipeline)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