private static NettyWebSocket getNettyWebSocket(NettyResponseFuture<?> future) throws Exception { return getWebSocketUpgradeHandler(future).onCompleted(); }
String connection = response.headers().get(CONNECTION); boolean validConnection = HttpHeaderValues.UPGRADE.contentEqualsIgnoreCase(connection); final boolean headerOK = handler.onHeadersReceived(responseHeaders) == State.CONTINUE; if (!headerOK || !validStatus || !validUpgrade || !validConnection) { requestSender.abort(channel, future, new IOException("Invalid handshake response")); handler.setWebSocket(new NettyWebSocket(channel, responseHeaders)); channelManager.upgradePipelineForWebSockets(channel.pipeline()); handler.onOpen(); } catch (Exception ex) { logger.warn("onSuccess unexpected exception", ex);
switch (handler.onStatusReceived(status)) { case CONTINUE: upgrade(channel, future, handler, response, responseHeaders);
connection = response.headers().get(HttpHeaders.Names.CONNECTION.toLowerCase(Locale.ENGLISH)); boolean validConnection = HttpHeaders.Values.UPGRADE.equalsIgnoreCase(connection); boolean statusReceived = handler.onStatusReceived(status) == State.UPGRADE; handler.onCompleted(); } finally { future.done(); final boolean headerOK = handler.onHeadersReceived(responseHeaders) == State.CONTINUE; if (!headerOK || !validStatus || !validUpgrade || !validConnection) { requestSender.abort(channel, future, new IOException("Invalid handshake response")); NettyWebSocket webSocket = NettyWebSocket.class.cast(handler.onCompleted()); invokeOnSucces(channel, handler); handler.onBodyPartReceived(part);
connection = response.headers().get(HttpHeaders.Names.CONNECTION.toLowerCase(Locale.ENGLISH)); boolean validConnection = HttpHeaders.Values.UPGRADE.equalsIgnoreCase(connection); boolean statusReceived = handler.onStatusReceived(status) == State.UPGRADE; handler.onCompleted(); } finally { future.done(); final boolean headerOK = handler.onHeadersReceived(responseHeaders) == State.CONTINUE; if (!headerOK || !validStatus || !validUpgrade || !validConnection) { requestSender.abort(channel, future, new IOException("Invalid handshake response"));
private void invokeOnSucces(Channel channel, WebSocketUpgradeHandler h) { if (!h.touchSuccess()) { try { h.onSuccess(nettyConfig.getNettyWebSocketFactory().newNettyWebSocket(channel, config)); } catch (Exception ex) { logger.warn("onSuccess unexpected exception", ex); } } }
NettyWebSocket webSocket = NettyWebSocket.class.cast(handler.onCompleted()); invokeOnSucces(channel, handler); try { NettyResponseBodyPart part = nettyConfig.getBodyPartFactory().newResponseBodyPart(buf, frame.isFinalFragment()); handler.onBodyPartReceived(part);
/** * Build a {@link WebSocketUpgradeHandler} * * @return a {@link WebSocketUpgradeHandler} */ public WebSocketUpgradeHandler build() { return new WebSocketUpgradeHandler(listeners); } }
connection = response.headers().get(HttpHeaders.Names.CONNECTION.toLowerCase(Locale.ENGLISH)); boolean validConnection = HttpHeaders.Values.UPGRADE.equalsIgnoreCase(connection); boolean statusReceived = handler.onStatusReceived(status) == State.UPGRADE; handler.onCompleted(); } finally { future.done(); final boolean headerOK = handler.onHeadersReceived(responseHeaders) == State.CONTINUE; if (!headerOK || !validStatus || !validUpgrade || !validConnection) { requestSender.abort(channel, future, new IOException("Invalid handshake response")); NettyWebSocket webSocket = NettyWebSocket.class.cast(handler.onCompleted()); invokeOnSucces(channel, handler); handler.onBodyPartReceived(part);
connection = response.headers().get(HttpHeaders.Names.CONNECTION.toLowerCase(Locale.ENGLISH)); boolean validConnection = HttpHeaders.Values.UPGRADE.equalsIgnoreCase(connection); boolean statusReceived = handler.onStatusReceived(status) == State.UPGRADE; handler.onCompleted(); } finally { future.done(); final boolean headerOK = handler.onHeadersReceived(responseHeaders) == State.CONTINUE; if (!headerOK || !validStatus || !validUpgrade || !validConnection) { requestSender.abort(channel, future, new IOException("Invalid handshake response"));
private void invokeOnSucces(Channel channel, WebSocketUpgradeHandler h) { if (!h.touchSuccess()) { try { h.onSuccess(nettyConfig.getNettyWebSocketFactory().newNettyWebSocket(channel, config)); } catch (Exception ex) { logger.warn("onSuccess unexpected exception", ex); } } }
NettyWebSocket webSocket = NettyWebSocket.class.cast(handler.onCompleted()); invokeOnSucces(channel, handler); if (buf != null && buf.readableBytes() > 0) { NettyResponseBodyPart part = nettyConfig.getBodyPartFactory().newResponseBodyPart(buf, frame.isFinalFragment()); handler.onBodyPartReceived(part);
/** * Build a {@link WebSocketUpgradeHandler} * * @return a {@link WebSocketUpgradeHandler} */ public WebSocketUpgradeHandler build() { return new WebSocketUpgradeHandler(listeners); } }
private void invokeOnSucces(Channel channel, WebSocketUpgradeHandler h) { if (!h.touchSuccess()) { try { h.onSuccess(nettyConfig.getNettyWebSocketFactory().newNettyWebSocket(channel, config)); } catch (Exception ex) { logger.warn("onSuccess unexpected exception", ex); } } }
@Override public void onClose(NettyResponseFuture<?> future) { logger.trace("onClose {}"); try { WebSocketUpgradeHandler h = WebSocketUpgradeHandler.class.cast(future); NettyWebSocket webSocket = NettyWebSocket.class.cast(h.onCompleted()); logger.trace("Connection was closed abnormally (that is, with no close frame being sent)."); if (webSocket != null) webSocket.close(1006, "Connection was closed abnormally (that is, with no close frame being sent)."); } catch (Throwable t) { logger.error("onError", t); } } }
private void invokeOnSucces(Channel channel, WebSocketUpgradeHandler h) { if (!h.touchSuccess()) { try { h.onSuccess(nettyConfig.getNettyWebSocketFactory().newNettyWebSocket(channel, config)); } catch (Exception ex) { logger.warn("onSuccess unexpected exception", ex); } } }
@Override public void onClose(NettyResponseFuture<?> future) { logger.trace("onClose"); try { WebSocketUpgradeHandler h = (WebSocketUpgradeHandler) future.getAsyncHandler(); NettyWebSocket webSocket = NettyWebSocket.class.cast(h.onCompleted()); logger.trace("Connection was closed abnormally (that is, with no close frame being sent)."); if (webSocket != null) webSocket.close(1006, "Connection was closed abnormally (that is, with no close frame being sent)."); } catch (Throwable t) { logger.error("onError", t); } } }
@Override public void onClose(NettyResponseFuture<?> future) { logger.trace("onClose {}"); try { WebSocketUpgradeHandler h = (WebSocketUpgradeHandler) future.getAsyncHandler(); NettyWebSocket webSocket = NettyWebSocket.class.cast(h.onCompleted()); logger.trace("Connection was closed abnormally (that is, with no close frame being sent)."); if (webSocket != null) webSocket.close(1006, "Connection was closed abnormally (that is, with no close frame being sent)."); } catch (Throwable t) { logger.error("onError", t); } } }
@Override public void onClose(NettyResponseFuture<?> future) { logger.trace("onClose"); try { WebSocketUpgradeHandler h = (WebSocketUpgradeHandler) future.getAsyncHandler(); NettyWebSocket webSocket = NettyWebSocket.class.cast(h.onCompleted()); logger.trace("Connection was closed abnormally (that is, with no close frame being sent)."); if (webSocket != null) webSocket.close(1006, "Connection was closed abnormally (that is, with no close frame being sent)."); } catch (Throwable t) { logger.error("onError", t); } } }
@Override public void onError(NettyResponseFuture<?> future, Throwable e) { logger.warn("onError {}", e); try { WebSocketUpgradeHandler h = (WebSocketUpgradeHandler) future.getAsyncHandler(); NettyWebSocket webSocket = NettyWebSocket.class.cast(h.onCompleted()); if (webSocket != null) { webSocket.onError(e.getCause()); webSocket.close(); } } catch (Throwable t) { logger.error("onError", t); } }