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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    install(io.netty.channel.ChannelHandlerContext ctx)
    Installs the shared SessionTouchHandler into the channel pipeline, if not already present.
    void
    write(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, read

    Methods inherited from class io.netty.channel.ChannelHandlerAdapter

    ensureNotSharable, exceptionCaught, handlerAdded, handlerRemoved, isSharable

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods 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 shared SessionTouchHandler into 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:
      write in interface io.netty.channel.ChannelOutboundHandler
      Overrides:
      write in class io.netty.channel.ChannelOutboundHandlerAdapter