@Override public void onStateChange(Connection connection, State newState) { for (ConnectionObserver observer : observers) { observer.onStateChange(connection, newState); } } }
/** * React on connection fatal error, will request a disconnecting state * change by default. It should only catch exceptions that can't be consumed by a * {@link NettyInbound#receive} subscriber. * * @param connection the remote connection * @param error the failing cause */ default void onUncaughtException(Connection connection, Throwable error) { onStateChange(connection, State.DISCONNECTING); }
@Override public void onStateChange(Connection connection, State newState) { for (ConnectionObserver observer : observers) { observer.onStateChange(connection, newState); } } }
/** * React on connection fatal error, will request a disconnecting state * change by default. It should only catch exceptions that can't be consumed by a * {@link NettyInbound#receive} subscriber. * * @param connection the remote connection * @param error the failing cause */ default void onUncaughtException(Connection connection, Throwable error) { onStateChange(connection, State.DISCONNECTING); }
@Override public void onStateChange(Connection connection, State newState) { if (newState == State.CONFIGURED) { sink.success(connection); } obs.onStateChange(connection, newState); }
@Override public void onStateChange(Connection connection, State newState) { if (newState == State.CONFIGURED) { sink.success(connection); } obs.onStateChange(connection, newState); }
@Override public void channelActive(ChannelHandlerContext ctx) { Connection c = Connection.from(ctx.channel()); listener.onStateChange(c, ConnectionObserver.State.CONNECTED); ChannelOperations<?, ?> ops = opsFactory.create(c, listener, null); if (ops != null) { ops.bind(); listener.onStateChange(ops, ConnectionObserver.State.CONFIGURED); } }
@Override public void channelActive(ChannelHandlerContext ctx) { Connection c = Connection.from(ctx.channel()); listener.onStateChange(c, ConnectionObserver.State.CONNECTED); ChannelOperations<?, ?> ops = opsFactory.create(c, listener, null); if (ops != null) { ops.bind(); listener.onStateChange(ops, ConnectionObserver.State.CONFIGURED); } }
@Override public void onStateChange(Connection connection, State newState) { if (newState == State.DISCONNECTING) { if (connection.channel() .isActive() && !connection.isPersistent()) { connection.dispose(); } } childObs.onStateChange(connection, newState); } }
@Override public void onStateChange(Connection connection, State newState) { if (newState == State.DISCONNECTING) { if (connection.channel() .isActive() && !connection.isPersistent()) { connection.dispose(); } } childObs.onStateChange(connection, newState); } }
@Override public void channelActive(ChannelHandlerContext ctx) { ChannelOperations<?, ?> ops = Connection.from(ctx.channel()).as(ChannelOperations.class); if (ops != null) { ops.listener().onStateChange(ops, ConnectionObserver.State.CONFIGURED); } ctx.fireChannelActive(); }
@Override public void channelActive(ChannelHandlerContext ctx) { ChannelOperations<?, ?> ops = Connection.from(ctx.channel()).as(ChannelOperations.class); if (ops != null) { ops.listener().onStateChange(ops, ConnectionObserver.State.CONFIGURED); } ctx.fireChannelActive(); }
@Override final public void channelInactive(ChannelHandlerContext ctx) { try { ChannelOperations<?, ?> ops = ChannelOperations.get(ctx.channel()); if (ops != null) { ops.onInboundClose(); } else { listener.onStateChange(Connection.from(ctx.channel()), ConnectionObserver.State.DISCONNECTING); } } catch (Throwable err) { Exceptions.throwIfFatal(err); exceptionCaught(ctx, err); } }
@Override final public void channelInactive(ChannelHandlerContext ctx) { try { ChannelOperations<?, ?> ops = ChannelOperations.get(ctx.channel()); if (ops != null) { ops.onInboundClose(); } else { listener.onStateChange(Connection.from(ctx.channel()), ConnectionObserver.State.DISCONNECTING); } } catch (Throwable err) { Exceptions.throwIfFatal(err); exceptionCaught(ctx, err); } }
@Override public void onStateChange(Connection connection, State newState) { if (log.isDebugEnabled()) { log.debug(format(connection.channel(), "onStateChange({}, {})"), newState, connection); } if (newState == State.CONFIGURED) { sink.success(connection); } else if (newState == State.DISCONNECTING && connection.channel() .isActive()) { connection.channel() .close(); } obs.onStateChange(connection, newState); }
@Override public void onStateChange(Connection connection, State newState) { if (log.isDebugEnabled()) { log.debug(format(connection.channel(), "onStateChange({}, {})"), newState, connection); } if (newState == State.CONFIGURED) { sink.success(connection); } else if (newState == State.DISCONNECTING && connection.channel() .isActive()) { connection.channel() .close(); } obs.onStateChange(connection, newState); }
@Override protected void onOutboundComplete() { if (isWebsocket() || isInboundCancelled()) { return; } if (markSentHeaderAndBody()) { if (log.isDebugEnabled()) { log.debug(format(channel(), "No sendHeaders() called before complete, sending " + "zero-length header")); } channel().writeAndFlush(newFullEmptyBodyMessage()); } else if (markSentBody()) { channel().writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT); } listener().onStateChange(this, HttpClientState.REQUEST_SENT); channel().read(); }
@Override protected void onOutboundComplete() { if (isWebsocket() || isInboundCancelled()) { return; } if (markSentHeaderAndBody()) { if (log.isDebugEnabled()) { log.debug(format(channel(), "No sendHeaders() called before complete, sending " + "zero-length header")); } channel().writeAndFlush(newFullEmptyBodyMessage()); } else if (markSentBody()) { channel().writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT); } listener().onStateChange(this, HttpClientState.REQUEST_SENT); channel().read(); }
@Override protected void onInboundClose() { if (isInboundCancelled() || isInboundDisposed()) { return; } listener().onStateChange(this, HttpClientState.RESPONSE_INCOMPLETE); if (responseState == null) { if (markSentBody()) { listener().onUncaughtException(this, PrematureCloseException.BEFORE_RESPONSE_SENDING_REQUEST); } else { listener().onUncaughtException(this, PrematureCloseException.BEFORE_RESPONSE); } return; } super.onInboundError(PrematureCloseException.DURING_RESPONSE); }
@Override protected void onInboundClose() { if (isInboundCancelled() || isInboundDisposed()) { return; } listener().onStateChange(this, HttpClientState.RESPONSE_INCOMPLETE); if (responseState == null) { if (markSentBody()) { listener().onUncaughtException(this, PrematureCloseException.BEFORE_RESPONSE_SENDING_REQUEST); } else { listener().onUncaughtException(this, PrematureCloseException.BEFORE_RESPONSE); } return; } super.onInboundError(PrematureCloseException.DURING_RESPONSE); }