function bindCloudflareSocketToSink
Since 0.2.0
bindCloudflareSocketToSink(
sink: WebSocketEventSink
): void

Binds a Workers server socket's events to a sink.

accept() is called first — a Workers socket cannot send or receive until it is accepted — and the sink's onOpen fires immediately afterwards, because Workers emits no open event for the server half of a pair.

Parameters

The server half of the pair

sink: WebSocketEventSink

The sink to drive

Return Type

void

Usage

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