interface WebSocketRoom
Since 0.2.0

A named broadcast group of connections — the bidirectional analogue of the SSE plugin's channels.

Connections are removed automatically when they close, so a room never broadcasts to a dead peer.

Properties

readonly
name: string

The room name.

readonly
size: number

Number of currently open members.

Methods

Adds a connection to this room.

Removes a connection from this room.

broadcast(
data: string | Uint8Array,
): void

Sends a frame to every open member, skipping any closed member and any member named by options.except.

broadcastJson<T>(
payload: T,
): void

Serializes a value to JSON once and broadcasts it as a text frame.

Usage

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