class SseConnection
implements IConn
Since 0.1.0

Implements IConn.

Constructors

SseConnection(
ctx: IRequestContext,
runtime: IRuntimeServices,
heartbeatMs: number | undefined,
retryMs: number | undefined,
onClosed: () => void
)

Properties

readonly
id: string

Unique connection ID.

readonly
isOpen: boolean

Whether this connection is still open.

readonly
lastEventId: string | null

The client's Last-Event-ID header value, if present.

readonly
result: HandlerResult

The HandlerResult obtained from ctx.response.stream() — set in constructor.

Methods

close(): void

Close the connection (idempotent).

comment(text: string): void

Enqueue a plain-text comment frame.

send(msg: SseMessage): void

Enqueue an encoded SSE message.

Usage

import { SseConnection } from "sse-plugin/src/index.ts";