Creates a new WebSocketDriver instance with the specified options.
Optionaloptions: {Configuration options for the driver.
OptionalpingInterval?: numberInterval for sending ping messages in ms (default: 30000).
OptionalpingTimeout?: numberTimeout for receiving pong responses in ms (default: 10000).
Optionalprotocols?: string | string[]Optional subprotocols for the WebSocket connection.
OptionalqueueLimit?: numberMaximum number of queued messages when socket is not opened (default: 100).
OptionalrandomizationFactor?: numberRandomization factor for reconnection delay (default: 0.5).
Optionalreconnection?: booleanWhether to enable auto-reconnection (default: true).
OptionalreconnectionAttempts?: numberMaximum number of reconnection attempts (default: Infinity).
OptionalreconnectionDelay?: numberInitial delay for reconnection attempts in ms (default: 5000).
OptionalreconnectionDelayMax?: numberMaximum delay for reconnection attempts in ms (default: 60000).
Optionalurl?: stringThe WebSocket server URL (default: '/ws').
Readonly[toReadonlysizeStatic Readonly[species]Indicates whether the WebSocket connection is currently open.
Returns an iterable of entries in the map.
Closes the WebSocket connection and clears all handlers and queued messages.
true if an element in the Map existed and has been removed, or false if the element does not exist.
Publish a signaling message to a namespace.
Target namespace segments.
Returns an iterable of key, value pairs for every entry in the map.
Executes a provided function once per each key/value pair in the Map, in insertion order.
OptionalthisArg: anyReturns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map.
Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.
boolean indicating whether an element with the specified key exists or not.
Returns an iterable of keys in the map
Unsubscribe a previously registered namespace handler.
Namespace segments used for message routing.
Handler reference originally passed to on.
Subscribe to signaling messages in a namespace.
Namespace segments used for message routing.
Callback invoked with message payload.
Opens a WebSocket connection to the server.
Adds a new element with a specified key and value to the Map. If an element with the same key already exists, the element will be updated.
Returns an iterable of values in the map
Staticgroup
WebSocket-based signaling driver with auto-reconnection and ping/pong support. It maintains a map of namespaces to sets of handlers, and automatically re-subscribes to namespaces after reconnection. It also queues messages when the socket is not opened, and flushes them upon connection.
Example