Class SessionTouchHandler
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelOutboundHandlerAdapter
dev.tachyonmcp.core.transport.netty.SessionTouchHandler
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelOutboundHandler
@Sharable
public final class SessionTouchHandler
extends io.netty.channel.ChannelOutboundHandlerAdapter
Outbound handler that refreshes session liveness on every byte written to the channel.
Any outbound HTTP writing — SSE frames, heartbeat comments, notifications, responses —
traverses this handler and calls
Session.touch(), keeping the
session alive without scattered touch() calls across the codebase.
Shared across all pipelines (@Sharable, stateless). Install via
install(ChannelHandlerContext) at the point where a session is bound to the channel.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidinstall(io.netty.channel.ChannelHandlerContext ctx) Installs the sharedSessionTouchHandlerinto the channel pipeline, if not already present.voidwrite(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise) Methods inherited from class io.netty.channel.ChannelOutboundHandlerAdapter
bind, close, connect, deregister, disconnect, flush, readMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, exceptionCaught, handlerAdded, handlerRemoved, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty.channel.ChannelHandler
exceptionCaught, handlerAdded, handlerRemoved
-
Constructor Details
-
SessionTouchHandler
public SessionTouchHandler()
-
-
Method Details
-
install
public static void install(io.netty.channel.ChannelHandlerContext ctx) Installs the sharedSessionTouchHandlerinto the channel pipeline, if not already present. Safe to call multiple times per channel. In production the pipeline always has an"http"(HttpServerCodec) handler, so the handler is added after it. In test pipelines without one, the handler is appended at the end. -
write
public void write(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise) - Specified by:
writein interfaceio.netty.channel.ChannelOutboundHandler- Overrides:
writein classio.netty.channel.ChannelOutboundHandlerAdapter
-