createWebSocketClient
Opens a WebSocket and keeps it open: a drop is retried with backoff.
Opens a WebSocket and keeps it open: a drop is retried with backoff. A close the client asked for
(close()) is final. Messages arrive in order; a text message is parsed with parse.
Import#
ts
import { createWebSocketClient } from "@shadow-js/dusk/client";
Signature#
ts
function createWebSocketClient<T = unknown>(
options: WebSocketClientOptions<T>,
): WebSocketClient
Parameters#
| Name | Description |
|---|---|
options |
The URL, the handler and the policy. |
Returns#
The client.
Examples#
ts
const chat = createWebSocketClient({ url: "/chat", onMessage: (data) => console.log(data) });
chat.send("hello");