@Override protected void addPushHandlers(final ChannelPipeline pipeline) { pipeline.addLast(PushAuthHandler.NAME, pushAuthHandler); pipeline.addLast(new WebSocketServerCompressionHandler()); pipeline.addLast(new WebSocketServerProtocolHandler(PushProtocol.WEBSOCKET.getPath(), null, true)); pipeline.addLast(new PushRegistrationHandler(pushConnectionRegistry, PushProtocol.WEBSOCKET)); pipeline.addLast(new SampleWebSocketPushClientProtocolHandler()); }
WebSocketServerProtocolHandler.setHandshaker(ctx.channel(), handshaker); ctx.pipeline().replace(this, "WS403Responder", WebSocketServerProtocolHandler.forbiddenHttpRequestResponder());
@Override protected void decode(ChannelHandlerContext ctx, WebSocketFrame frame, List<Object> out) throws Exception { if (frame instanceof CloseWebSocketFrame) { WebSocketServerHandshaker handshaker = getHandshaker(ctx.channel()); if (handshaker != null) { frame.retain(); handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame); } else { ctx.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE); } return; } super.decode(ctx, frame, out); }
private void switchToWebsocket( ChannelHandlerContext ctx ) { ChannelPipeline p = ctx.pipeline(); p.addLast( new HttpServerCodec(), new HttpObjectAggregator( MAX_WEBSOCKET_HANDSHAKE_SIZE ), new WebSocketServerProtocolHandler( "/", null, false, MAX_WEBSOCKET_FRAME_SIZE ), new WebSocketFrameAggregator( MAX_WEBSOCKET_FRAME_SIZE ), new WebSocketFrameTranslator(), newHandshaker() ); p.remove( this ); }
WebSocketServerProtocolHandler.setHandshaker(ctx.channel(), handshaker); ctx.pipeline().replace(this, "WS403Responder", WebSocketServerProtocolHandler.forbiddenHttpRequestResponder());
@Override protected void decode(ChannelHandlerContext ctx, WebSocketFrame frame, List<Object> out) throws Exception { if (frame instanceof CloseWebSocketFrame) { WebSocketServerHandshaker handshaker = getHandshaker(ctx.channel()); if (handshaker != null) { frame.retain(); handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame); } else { ctx.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE); } return; } super.decode(ctx, frame, out); }
@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()); }
WebSocketServerProtocolHandler.setHandshaker(ctx.channel(), handshaker); ctx.pipeline().replace(this, "WS403Responder", WebSocketServerProtocolHandler.forbiddenHttpRequestResponder());
@Override protected void decode(ChannelHandlerContext ctx, WebSocketFrame frame, List<Object> out) throws Exception { if (frame instanceof CloseWebSocketFrame) { WebSocketServerHandshaker handshaker = getHandshaker(ctx.channel()); if (handshaker != null) { frame.retain(); handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame); } else { ctx.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE); } return; } super.decode(ctx, frame, out); }
@Override void init(SocketChannel channel) { ChannelPipeline pipeline = channel.pipeline(); pipeline.addLast(new HttpServerCodec()); pipeline.addLast("aggregator", new HttpObjectAggregator(65536)); pipeline.addLast("webSocketHandler", new WebSocketServerProtocolHandler("/mqtt", MQTT_SUBPROTOCOL_CSV_LIST)); pipeline.addLast("ws2bytebufDecoder", new WebSocketFrameToByteBufDecoder()); pipeline.addLast("bytebuf2wsEncoder", new ByteBufToWebSocketFrameEncoder()); configureMQTTPipeline(pipeline, timeoutHandler, handler); } });
WebSocketServerProtocolHandler.setHandshaker(ctx.channel(), handshaker); ctx.pipeline().replace(this, "WS403Responder", WebSocketServerProtocolHandler.forbiddenHttpRequestResponder());
@Override protected void decode(ChannelHandlerContext ctx, WebSocketFrame frame, List<Object> out) throws Exception { if (frame instanceof CloseWebSocketFrame) { WebSocketServerHandshaker handshaker = getHandshaker(ctx.channel()); if (handshaker != null) { frame.retain(); handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame); } else { ctx.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE); } return; } super.decode(ctx, frame, out); }
@Override protected void initChannel(Channel ch) throws Exception { ChannelPipeline pipeline = ch.pipeline(); pipeline.addLast(new HttpServerCodec()); pipeline.addLast(new ChunkedWriteHandler()); pipeline.addLast(new HttpObjectAggregator(64 * 1024)); pipeline.addLast(new HttpRequestHandler("/ws")); pipeline.addLast(new WebSocketServerProtocolHandler("/ws")); pipeline.addLast(new TextWebSocketFrameHandler(group)); } }
WebSocketServerProtocolHandler.setHandshaker(ctx.channel(), handshaker); ctx.pipeline().replace(this, "WS403Responder", WebSocketServerProtocolHandler.forbiddenHttpRequestResponder());
@Override protected void decode(ChannelHandlerContext ctx, WebSocketFrame frame, List<Object> out) throws Exception { if (frame instanceof CloseWebSocketFrame) { WebSocketServerHandshaker handshaker = getHandshaker(ctx.channel()); if (handshaker != null) { frame.retain(); handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame); } else { ctx.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE); } return; } super.decode(ctx, frame, out); }
@Override void init(SocketChannel channel) throws Exception { ChannelPipeline pipeline = channel.pipeline(); pipeline.addLast("ssl", createSslHandler(channel, sslContext, needsClientAuth)); pipeline.addLast("httpEncoder", new HttpResponseEncoder()); pipeline.addLast("httpDecoder", new HttpRequestDecoder()); pipeline.addLast("aggregator", new HttpObjectAggregator(65536)); pipeline.addLast("webSocketHandler", new WebSocketServerProtocolHandler("/mqtt", MQTT_SUBPROTOCOL_CSV_LIST)); pipeline.addLast("ws2bytebufDecoder", new WebSocketFrameToByteBufDecoder()); pipeline.addLast("bytebuf2wsEncoder", new ByteBufToWebSocketFrameEncoder()); configureMQTTPipeline(pipeline, timeoutHandler, handler); } });
private void initWebDashboardSocket(ChannelHandlerContext ctx) { var pipeline = ctx.pipeline(); //websockets specific handlers pipeline.addFirst("AChannelState", appChannelStateHandler) .addFirst("AReadTimeout", new IdleStateHandler(appIdleTimeout, 0, 0)) .addLast("WSWebSocketServerProtocolHandler", new WebSocketServerProtocolHandler(WEBSOCKET_WEB_PATH)) .addLast("WSMessageDecoder", new WSMessageDecoder(stats, holder.limits)) .addLast("WSMessageEncoder", webAppMessageEncoder) .addLast("AGetServer", getServerHandler) .addLast("ALogin", appLoginHandler) .addLast("ANotLogged", userNotLoggedHandler); pipeline.remove(ChunkedWriteHandler.class); pipeline.remove(UrlReWriterHandler.class); pipeline.remove(StaticFileHandler.class); pipeline.remove(this); if (log.isTraceEnabled()) { log.trace("Initialized web dashboard pipeline. {}", ctx.pipeline().names()); } }
private void initWebSocketPipeline(ChannelHandlerContext ctx, String websocketPath) { var pipeline = ctx.pipeline(); //websockets specific handlers pipeline.addFirst("WSIdleStateHandler", new IdleStateHandler(hardwareIdleTimeout, 0, 0)) .addLast("WSChannelState", hardwareChannelStateHandler) .addLast("WSWebSocketServerProtocolHandler", new WebSocketServerProtocolHandler(websocketPath, true)) .addLast("WSWebSocket", webSocketHandler) .addLast("WSMessageDecoder", new MessageDecoder(stats, holder.limits)) .addLast("WSSocketWrapper", webSocketWrapperEncoder) .addLast("WSMessageEncoder", new MessageEncoder(stats)) .addLast("WSLogin", hardwareLoginHandler) .addLast("WSNotLogged", alreadyLoggedHandler); pipeline.remove(ChunkedWriteHandler.class); pipeline.remove(UrlReWriterHandler.class); pipeline.remove(StaticFileHandler.class); pipeline.remove(this); if (log.isTraceEnabled()) { log.trace("Initialized secured hardware websocket pipeline. {}", ctx.pipeline().names()); } } };
@Override protected void initChannel(Channel ch) throws Exception { ch.pipeline().addLast( new HttpServerCodec(), new HttpObjectAggregator(65536), new WebSocketServerProtocolHandler("/websocket"), new TextFrameHandler(), new BinaryFrameHandler(), new ContinuationFrameHandler()); }
private void initWebSocketPipeline(ChannelHandlerContext ctx, String websocketPath) { var pipeline = ctx.pipeline(); //websockets specific handlers pipeline.addFirst("WSIdleStateHandler", new IdleStateHandler(hardTimeoutSecs, 0, 0)) .addLast("WSChannelState", hardwareChannelStateHandler) .addLast("WSWebSocketServerProtocolHandler", new WebSocketServerProtocolHandler(websocketPath, true)) .addLast("WSWebSocket", new WSHandler(stats)) .addLast("WSMessageDecoder", new MessageDecoder(stats, holder.limits)) .addLast("WSSocketWrapper", new WSWrapperEncoder()) .addLast("WSMessageEncoder", new MessageEncoder(stats)) .addLast("WSLogin", hardwareLoginHandler) .addLast("WSNotLogged", alreadyLoggedHandler) .remove(this); if (log.isTraceEnabled()) { log.trace("Initialized hardware websocket pipeline. {}", ctx.pipeline().names()); } } };