function createDefaultDurableObjectWebSocketHost
Since 0.2.0
createDefaultDurableObjectWebSocketHost(): DurableObjectWebSocketHost

Builds the default host from the real Workers global.

Exported as a factory rather than a constant so the boundary cast runs only when an upgrade happens — importing this module on Deno must not throw — and so a unit test can drive the default path directly.

Examples

Example 1

// Inside the Durable Object class the application exports:
const core = new RealtimeBackplaneObjectCore(this.ctx, {
  createPair: createDefaultDurableObjectWebSocketHost(),
});

Return Type

A host backed by the WebSocketPair global

Throws

Error

When WebSocketPair is absent, i.e. off the Workers runtime, or when the global yields an incomplete pair

Usage

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