Actors/Packages/WebSocket/API reference
@sigx/actors-ws · Preview

API reference#

Exports of @sigx/actors-ws v0.1.0.

wsTransport(options)#

Returns a WsTransportHandle — a callable HostTransportFactory that also carries attach.

TypeScript
interface WsTransportOptions {
    advertiseUrl: () => string | Promise<string>;   // required
    path?: string;             // '/_sigx/host-ws'
    maxFrameBytes?: number;
    credit?: number;
    keepAliveMs?: number;
    connect?: (url: string) => MinimalWebSocket;
}
TypeScript
// attach(server: Server, options?: { wss?: WebSocketServerLike }): Promise<() => void>

const stop = await ws.attach(server);                       // usual case
const stop = await ws.attach(server, { wss: myWsServer });   // reuse your own

attachHostUpgrade(server, { transport, wss? })#

The standalone form, for when you already hold a transport instance rather than letting cluster() build one.

Constants#

ExportValue
WS_TRANSPORT_NAME'ws' — the key under HostDescriptor.addresses
DEFAULT_WS_PATH/_sigx/host-ws

Types#

WsHostTransport, UpgradeOptions, WebSocketServerLike, MinimalWebSocket.

webSocketLink is exported for transport authors wiring the client half by hand.

Re-exported frame codec#

DEFAULT_CREDIT, DEFAULT_MAX_FRAME_BYTES — shared with @sigx/actors-tcp, and also available from @sigx/actors/cluster/frames.

Next steps#