Class OutboundSseStreamMessageRouter

java.lang.Object
dev.tachyonmcp.core.server.OutboundSseStreamMessageRouter
All Implemented Interfaces:
OutboundStreamResolver

@InternalApi public final class OutboundSseStreamMessageRouter extends Object implements OutboundStreamResolver
Default OutboundStreamResolver that diverts events through an OutboundSseStream bound in the current dispatch context when the dispatch session matches the target session. Otherwise, lets the caller fall through to the normal GET-SSE path.
  • Constructor Details

    • OutboundSseStreamMessageRouter

      public OutboundSseStreamMessageRouter()
  • Method Details

    • withDispatchContext

      public static <T> T withDispatchContext(@Nullable String sessionId, @Nullable OutboundSseStream outboundSseStream, Callable<T> action) throws Exception
      Throws:
      Exception
    • currentOutboundSseStream

      public static @Nullable OutboundSseStream currentOutboundSseStream()
    • currentSessionId

      public static @Nullable String currentSessionId()
    • resolve

      public @Nullable OutboundSseStream resolve(Session session)
      Description copied from interface: OutboundStreamResolver
      Resolves the OutboundSseStream bound in the current dispatch context for the given session, if any. The caller needs the stream before building the event (its OutboundSseStream.streamKey() goes into the SSE event id and the event log), so resolution and delivery are separate steps.
      Specified by:
      resolve in interface OutboundStreamResolver
      Parameters:
      session - the target session for the event
      Returns:
      the bound stream to deliver on, or null to fall through to the session's GET-SSE connection