static void registerForClose(boolean shouldCleanupOnClose, String name, Connection context) { if (!shouldCleanupOnClose) return; context.onTerminate().subscribe(null, null, () -> context.removeHandler(name)); }
static void registerForClose(boolean shouldCleanupOnClose, String name, Connection context) { if (!shouldCleanupOnClose) return; context.onTerminate().subscribe(null, null, () -> context.removeHandler(name)); }
/** * Assign a {@link Runnable} to be invoked when reads have become idle for the given * timeout. This replaces any previously set idle callback. * * @param idleTimeout the idle timeout * @param onReadIdle the idle timeout handler * * @return {@literal this} */ default Connection onReadIdle(long idleTimeout, Runnable onReadIdle) { return removeHandler(NettyPipeline.OnChannelReadIdle) .addHandlerFirst(NettyPipeline.OnChannelReadIdle, new ReactorNetty.InboundIdleStateHandler(idleTimeout, onReadIdle)); }
/** * Assign a {@link Runnable} to be invoked when writes have become idle for the given * timeout. This replaces any previously set idle callback. * * @param idleTimeout the idle timeout * @param onWriteIdle the idle timeout handler * * @return {@literal this} */ default Connection onWriteIdle(long idleTimeout, Runnable onWriteIdle) { return removeHandler(NettyPipeline.OnChannelWriteIdle) .addHandlerFirst(NettyPipeline.OnChannelWriteIdle, new ReactorNetty.OutboundIdleStateHandler(idleTimeout, onWriteIdle)); }
/** * Assign a {@link Runnable} to be invoked when writes have become idle for the given * timeout. This replaces any previously set idle callback. * * @param idleTimeout the idle timeout * @param onWriteIdle the idle timeout handler * * @return {@literal this} */ default Connection onWriteIdle(long idleTimeout, Runnable onWriteIdle) { return removeHandler(NettyPipeline.OnChannelWriteIdle) .addHandlerFirst(NettyPipeline.OnChannelWriteIdle, new ReactorNetty.OutboundIdleStateHandler(idleTimeout, onWriteIdle)); }
/** * Assign a {@link Runnable} to be invoked when reads have become idle for the given * timeout. This replaces any previously set idle callback. * * @param idleTimeout the idle timeout * @param onReadIdle the idle timeout handler * * @return {@literal this} */ default Connection onReadIdle(long idleTimeout, Runnable onReadIdle) { return removeHandler(NettyPipeline.OnChannelReadIdle) .addHandlerFirst(NettyPipeline.OnChannelReadIdle, new ReactorNetty.InboundIdleStateHandler(idleTimeout, onReadIdle)); }
static void autoAddHttpExtractor(Connection c, String name, ChannelHandler handler){ if (handler instanceof ByteToMessageDecoder || handler instanceof ByteToMessageCodec || handler instanceof CombinedChannelDuplexHandler) { String extractorName = name+"$extractor"; if(c.channel().pipeline().context(extractorName) != null){ return; } c.channel().pipeline().addBefore(name, extractorName, HTTP_EXTRACTOR); if(c.isPersistent()){ c.onTerminate().subscribe(null, null, () -> c.removeHandler(extractorName)); } } }
static void autoAddHttpExtractor(Connection c, String name, ChannelHandler handler){ if (handler instanceof ByteToMessageDecoder || handler instanceof ByteToMessageCodec || handler instanceof CombinedChannelDuplexHandler) { String extractorName = name+"$extractor"; if(c.channel().pipeline().context(extractorName) != null){ return; } c.channel().pipeline().addBefore(name, extractorName, HTTP_EXTRACTOR); if(c.isPersistent()){ c.onTerminate().subscribe(null, null, () -> c.removeHandler(extractorName)); } } }