Setu-TS
    Preparing search index...

    Interface ISseService

    Service contract for the SSE hub — registered by the SsePlugin under CAPABILITIES.SSE.

    import { CAPABILITIES } from '@setu-ts/common';

    const sse = ctx.services.get<ISseService>(CAPABILITIES.SSE);
    const conn = sse.open(ctx);
    conn.send({ data: 'hello' });

    0.1.0

    interface ISseService {
        channelCount: number;
        connectionCount: number;
        channel(name: string): SseChannel;
        open(ctx: IRequestContext): ISseConnection;
        peek(name: string): SseChannel | undefined;
    }

    Implemented by

    Index
    channelCount: number

    Number of channels with members. Drops when a last member leaves and becomes zero when shutdown clears the registry.

    0.4.0

    connectionCount: number

    Current number of open connections.

    • Returns a reusable named channel handle. Membership is allocated on add and reclaimed when the last member leaves. Held handles resolve members by name and remain usable after reclamation.

      Parameters

      • name: string

        Channel name

      Returns SseChannel

      The named channel

    • Opens a new SSE connection for the given request context.

      Constructs a ReadableStream, captures its controller, sets the SSE response headers on the context's response builder, calls ctx.response.stream(rs) to obtain the HandlerResult, and returns a connection the handler can use to send messages after the handler returns.

      Parameters

      Returns ISseConnection

      The SSE connection with its result

    • Returns the named channel when it has members, without creating a handle or membership entry. Empty channels return undefined.

      Parameters

      • name: string

        Channel name

      Returns SseChannel | undefined

      The channel, or undefined when it has no members

      const subscribers = sse.peek(`build:${id}`)?.size ?? 0;
      

      0.4.0