createWsClientTransport
The createWsClientTransport function wraps a WebSocket in a WsClientTransport implementation.
createWsClientTransport<WebSocketType>(
webSocket: WebSocketType,
options?: TransportOptions,
): WsClientTransport<WebSocketType>| Type | Description | |
|---|---|---|
webSocket | WebSocketType | The WebSocket instance to wrap (browser WebSocket or ws WebSocket). |
options? | TransportOptions | Optional |
| returns | WsClientTransport<WebSocketType> | A |
This transport enables real-time synchronization over network connections, allowing Synclets to communicate across different machines, processes, or browser tabs. It handles automatic reconnection, packet fragmentation for large payloads, and bidirectional communication.
The client transport can only connect to servers created with createWsBroker (or another Synclet running WsBrokerTransport). It is suitable for browser environments (using the Web API WebSocket) and Node.js (using the 'ws' package).
Since
v0.0.0