function bindWsSocketToSink
Since 0.2.0
bindWsSocketToSink(
socket: WsSocketLike,
sink: WebSocketEventSink
): void

Binds a ws socket's events to a sink.

ws delivers a completed socket already open, so onOpen fires immediately rather than waiting for an event that will never arrive. Its close reason arrives as a Buffer, and binary frames as a Buffer too — both are Uint8Array subclasses, so the shared frame normalization handles them.

Parameters

The ws socket

sink: WebSocketEventSink

The sink to drive

Return Type

void

Usage

import { bindWsSocketToSink } from "runtime/src/index.ts";