interface ISseConnection
Since 0.1.0

A live SSE connection backed by a ReadableStream.

The connection owns its stream lifecycle (heartbeat interval, controller, abort listener) and exposes send, comment, and close.

Properties

readonly
id: string

Unique connection ID.

readonly
lastEventId: string | null

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

readonly
isOpen: boolean

Whether this connection is still open.

The HandlerResult obtained from ctx.response.stream(). The handler returns this value so the kernel maps it to the correct web response.

Methods

send(msg: SseMessage): void

Enqueues an encoded SSE frame for the connected client.

comment(text: string): void

Enqueues a plain-text comment frame (: <text>\n\n) — commonly used as a keep-alive heartbeat.

close(): void

Closes the connection: clears the heartbeat, closes the stream controller, and marks the connection as closed. Idempotent.

Usage

import { type ISseConnection } from "common/src/index.ts";