@Override public void initChannel(SocketChannel ch) { ChannelPipeline p = ch.pipeline(); p.addLast(new ReadTimeoutHandler(60, TimeUnit.SECONDS)); if (sslContext != null) { p.addLast(sslContext.newHandler(ch.alloc())); } p.addLast(new HttpContentCompressor(5)); p.addLast(new HttpServerCodec()); p.addLast(new HttpObjectAggregator(1048576)); p.addLast(new ChunkedWriteHandler()); if (null != corsConfig) { p.addLast(new CorsHandler(corsConfig)); } p.addLast(new WebSocketServerCompressionHandler()); p.addLast(new WebSocketServerProtocolHandler(webSocketPath, null, true)); p.addLast(new LaputaServerHandler(null != sslContext, requestProcessor)); }
private void switchToHttp(ChannelHandlerContext ctx) { ChannelPipeline p = ctx.pipeline(); p.addLast(new HttpServerCodec()); p.addLast(new HttpObjectAggregator(65536)); p.addLast(new WebSocketServerCompressionHandler()); p.addLast(new WebSocketServerProtocolHandler(WEBSOCKET_PATH, "ws", true)); p.addLast(new NetoJsonStringToMapWebSocketDecoder()); p.addLast(new NetoMessageToWebsocketFrameEncoder()); p.remove(this); // 핸들러를 다시 등록 했으므로 이벤트를 전파 ctx.fireChannelActive(); }
@Override public void initChannel(SocketChannel ch) throws Exception { ChannelPipeline pipeline = ch.pipeline(); if (sslCtx != null) { pipeline.addLast(sslCtx.newHandler(ch.alloc())); } pipeline.addLast(new HttpServerCodec()); pipeline.addLast(new HttpObjectAggregator(65536)); pipeline.addLast(new WebSocketServerCompressionHandler()); pipeline.addLast(new WebSocketServerProtocolHandler(WEBSOCKET_PATH, "binary", true)); pipeline.addLast(new WebSocketIndexPageHandler(pluginDataFolder)); pipeline.addLast(new WebSocketFrameHandler(webSocketServerThread, checkIPBans)); }
@Override protected void initPipeline(ChannelPipeline pipeline) { pipeline.addLast(new HttpServerCodec()); pipeline.addLast(new HttpObjectAggregator(65536)); pipeline.addLast(new WebSocketServerCompressionHandler()); pipeline.addLast(new WebSocketServerProtocolHandler(CC.mp.net.ws_path, null, true)); pipeline.addLast(new WebSocketIndexPageHandler()); pipeline.addLast(getChannelHandler()); }
/** * 채널 파이프라인 설정. * Netty.Server.Configuration.NettyServerConfiguration 에서 등록한 Bean 을 이용해 사용자의 통신을 처리할 Handler 도 등록. * Netty.Server.Handler.JsonHandler 에서 실제 사용자 요청 처리. * * @param channel * @throws Exception */ @Override protected void initChannel(Channel channel) throws Exception { ChannelPipeline channelPipeline = channel.pipeline(); switch (transferType) { case "websocket": channelPipeline .addLast(new HttpServerCodec()) .addLast(new HttpObjectAggregator(65536)) .addLast(new WebSocketServerCompressionHandler()) .addLast(new WebSocketServerProtocolHandler(transferWebsocketPath, transferWebsocketSubProtocol, transferWebsocketAllowExtensions)) .addLast(new LoggingHandler(LogLevel.valueOf(logLevelPipeline))) .addLast(websocketHandler); case "tcp": default: channelPipeline .addLast(new LineBasedFrameDecoder(Integer.MAX_VALUE)) .addLast(STRING_DECODER) .addLast(STRING_ENCODER) .addLast(new LoggingHandler(LogLevel.valueOf(logLevelPipeline))) .addLast(jsonHandler); } }
@Override protected void initChannel(final SocketChannel ch) throws Exception { final 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(webSockServiceHandler); }
@Override public void initChannel(SocketChannel ch) throws Exception { ChannelPipeline pipeline = ch.pipeline(); if (sslCtx != null) { pipeline.addLast(sslCtx.newHandler(ch.alloc())); } pipeline.addLast(new HttpServerCodec()); pipeline.addLast(new HttpObjectAggregator(65536)); pipeline.addLast(new WebSocketServerCompressionHandler()); pipeline.addLast(new WebSocketServerProtocolHandler(WEBSOCKET_PATH, subProtocols, true)); pipeline.addLast(new WebSocketRemoteServerFrameHandler()); }
@Override public void apply(ChannelPipeline pipeline){ pipeline.channel().config().setAutoRead(true); pipeline.addLast(new HttpServerCodec()); pipeline.addLast(new HttpObjectAggregator(65536)); if(Config.getInstance().isCompressionEnabled()){ pipeline.addLast(new WebSocketServerCompressionHandler()); } pipeline.addLast(guicer.inject(new WebSocketValidationHandler())); pipeline.addLast(guicer.inject(new WebSocketServerHandler())); }
@Override public void initChannel(SocketChannel ch) throws Exception { ChannelPipeline pipeline = ch.pipeline(); if (sslCtx != null) { pipeline.addLast(sslCtx.newHandler(ch.alloc())); } 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 WebSocketFrameHandler()); }
@Override public void initChannel(SocketChannel ch) throws Exception { ChannelPipeline pipeline = ch.pipeline(); if (sslCtx != null) { pipeline.addLast(sslCtx.newHandler(ch.alloc())); } 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 TextWebSocketFrameHandler()); }
@Override protected void initChannel(SocketChannel ch) throws Exception { 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 WatcherServerIndexPageHandler(WEBSOCKET_PATH)); pipeline.addLast(new WatcherServerHandler()); }
@Override protected void initChannel(Channel ch) throws Exception { ChannelPipeline pipeline = ch.pipeline(); // Flash policy file if (isFlashSupported) { pipeline.addLast(FLASH_POLICY_HANDLER, flashPolicyHandler); } // SSL if (sslContext != null) { pipeline.addLast(SSL_HANDLER, sslContext.newHandler(ch.alloc())); } // HTTP pipeline.addLast(HTTP_REQUEST_DECODER, new HttpRequestDecoder()); pipeline.addLast(HTTP_CHUNK_AGGREGATOR, new HttpObjectAggregator(MAX_HTTP_CONTENT_LENGTH)); pipeline.addLast(HTTP_RESPONSE_ENCODER, new HttpResponseEncoder()); if (isHttpCompressionEnabled) { pipeline.addLast(HTTP_COMPRESSION, new HttpContentCompressor()); } // Flash resources if (isFlashSupported) { pipeline.addLast(FLASH_RESOURCE_HANDLER, flashResourceHandler); } // Socket.IO pipeline.addLast(SOCKETIO_PACKET_ENCODER, packetEncoderHandler); pipeline.addLast(SOCKETIO_HANDSHAKE_HANDLER, handshakeHandler); pipeline.addLast(SOCKETIO_DISCONNECT_HANDLER, disconnectHandler); if (isWebsocketCompressionEnabled) { pipeline.addLast(WEBSOCKET_COMPRESSION, new WebSocketServerCompressionHandler()); } pipeline.addLast(SOCKETIO_WEBSOCKET_HANDLER, webSocketHandler); if (isFlashSupported) { pipeline.addLast(SOCKETIO_FLASHSOCKET_HANDLER, flashSocketHandler); } pipeline.addLast(SOCKETIO_XHR_POLLING_HANDLER, xhrPollingHandler); if (isJsonpSupported) { pipeline.addLast(SOCKETIO_JSONP_POLLING_HANDLER, jsonpPollingHandler); } pipeline.addLast(SOCKETIO_HEARTBEAT_HANDLER, heartbeatHandler); pipeline.addLast(eventExecutorGroup, SOCKETIO_PACKET_DISPATCHER, packetDispatcherHandler); if (pipelineModifier != null) { pipelineModifier.modifyPipeline(pipeline); } }