interface IDurableObjectWebSocket
Since 0.2.0

A WebSocket held by a Durable Object, as the hibernation API hands it back.

Deliberately narrower than the client-side socket below: a DO reaches its accepted sockets only through state.getWebSockets(), and drives them with send/close. It never adds listeners, because hibernation delivers incoming messages to the class's webSocketMessage handler instead.

Methods

send(message: string | ArrayBuffer): void

Sends one frame to the peer.

close(
code?: number,
reason?: string
): void

Closes the connection.

Usage

import { type IDurableObjectWebSocket } from "cloudflare-plugin/src/index.ts";