private void handshakeComplete(ChannelHandlerContext ctx, FullHttpResponse response) { handshaking = false; ChannelHandler handler = ctx.pipeline().get(HttpContentDecompressor.class); if (handler != null) { // remove decompressor as its not needed anymore once connection was upgraded to websockets ctx.pipeline().remove(handler); } WebSocketImpl webSocket = new WebSocketImpl(vertx, Http1xClientConnection.this, supportsContinuation, options.getMaxWebsocketFrameSize(), options.getMaxWebsocketMessageSize()); ws = webSocket; handshaker.finishHandshake(chctx.channel(), response); ws.subProtocol(handshaker.actualSubprotocol()); context.executeFromIO(v -> { log.debug("WebSocket handshake complete"); if (metrics != null ) { webSocket.setMetric(metrics.connected(endpointMetric, metric(), webSocket)); } webSocket.registerHandler(vertx.eventBus()); wsConnect.handle(webSocket); }); } }
private void handshakeComplete(ChannelHandlerContext ctx, FullHttpResponse response) { handshaking = false; ChannelHandler handler = ctx.pipeline().get(HttpContentDecompressor.class); if (handler != null) { // remove decompressor as its not needed anymore once connection was upgraded to websockets ctx.pipeline().remove(handler); } WebSocketImpl webSocket = new WebSocketImpl(vertx, Http1xClientConnection.this, supportsContinuation, options.getMaxWebsocketFrameSize(), options.getMaxWebsocketMessageSize()); ws = webSocket; handshaker.finishHandshake(chctx.channel(), response); ws.subProtocol(handshaker.actualSubprotocol()); context.executeFromIO(v -> { log.debug("WebSocket handshake complete"); if (metrics != null ) { webSocket.setMetric(metrics.connected(endpointMetric, metric(), webSocket)); } webSocket.registerHandler(vertx.eventBus()); wsConnect.handle(webSocket); }); } }
@Override public String selectedSubprotocol() { return handshaker.actualSubprotocol(); }
@Override public String selectedSubprotocol() { return handshaker.actualSubprotocol(); }
@Override public String selectedSubprotocol() { return handshaker.actualSubprotocol(); }
@Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception{ if(evt == WebSocketClientProtocolHandler.ClientHandshakeStateEvent.HANDSHAKE_COMPLETE){ NettyWebSocket webSocket = new NettyWebSocket(null, handshaker.actualSubprotocol()); ctx.pipeline().addLast("ws-aggregator", new WebSocketFrameAggregator(16 * 1024 * 1024)); // 16MB ctx.pipeline().addLast("websocket", webSocket); ctx.pipeline().remove(this); webSocket.channelActive(ctx); connectListener.onConnect(webSocket); }else ctx.fireUserEventTriggered(evt); } }
@Override public void operationComplete(ChannelFuture future) { Throwable cause = future.cause(); if (future.isSuccess() && cause == null) { WebSocketSessionImpl session = (WebSocketSessionImpl) handler.getChannelSession(); String actualSubProtocol = websocketHandshaker.actualSubprotocol(); handler.setActualSubProtocol(actualSubProtocol); session.setNegotiatedSubProtocol(actualSubProtocol); session.setIsOpen(true); handshakeFuture.notifySuccess(session); } else { handshakeFuture.notifyError(cause); } } }).sync();
false, secure, requestedUri, handshaker.actualSubprotocol(), connectorFuture, messageQueueHandler); channel.pipeline().addLast(Constants.WEBSOCKET_FRAME_HANDLER, inboundFrameHandler); channel.pipeline().remove(Constants.WEBSOCKET_CLIENT_HANDSHAKE_HANDLER);
@Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt == WebSocketClientProtocolHandler.ClientHandshakeStateEvent.HANDSHAKE_COMPLETE) { // Handshake is completed String actualProtocol = handshaker.actualSubprotocol(); serialization = WampSerialization.fromString(actualProtocol); if (serialization == WampSerialization.Invalid) { throw new WampError("Invalid Websocket Protocol"); } // Install the serializer and deserializer ctx.pipeline() .addAfter(ctx.name(), "wamp-deserializer", new WampDeserializationHandler(serialization)); ctx.pipeline() .addAfter(ctx.name(), "wamp-serializer", new WampSerializationHandler(serialization)); // Fire the connection established event ctx.fireUserEventTriggered(new ConnectionEstablishedEvent(serialization)); } else { ctx.fireUserEventTriggered(evt); } } }
@Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt == WebSocketClientProtocolHandler.ClientHandshakeStateEvent.HANDSHAKE_COMPLETE) { // Handshake is completed String actualProtocol = handshaker.actualSubprotocol(); serialization = WampSerialization.fromString(actualProtocol); if (serialization == WampSerialization.Invalid) { throw new WampError("Invalid Websocket Protocol"); } // Install the serializer and deserializer ctx.pipeline() .addAfter(ctx.name(), "wamp-deserializer", new WampDeserializationHandler(serialization)); ctx.pipeline() .addAfter(ctx.name(), "wamp-serializer", new WampSerializationHandler(serialization)); // Fire the connection established event ctx.fireUserEventTriggered(new ConnectionEstablishedEvent(serialization)); } else { ctx.fireUserEventTriggered(evt); } } }
@Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt == WebSocketClientProtocolHandler.ClientHandshakeStateEvent.HANDSHAKE_COMPLETE) { // Handshake is completed String actualProtocol = handshaker.actualSubprotocol(); serialization = WampSerialization.fromString(actualProtocol); if (serialization == WampSerialization.Invalid) { throw new WampError("Invalid Websocket Protocol"); } // Install the serializer and deserializer ctx.pipeline() .addAfter(ctx.name(), "wamp-deserializer", new WampDeserializationHandler(serialization)); ctx.pipeline() .addAfter(ctx.name(), "wamp-serializer", new WampSerializationHandler(serialization)); // Fire the connection established event ctx.fireUserEventTriggered(new ConnectionEstablishedEvent(serialization)); } else { ctx.fireUserEventTriggered(evt); } } }