ProtectedconnectionProtectedcleanupThe WebSocket client to clean up.
void
ProtectedclearClears all timers associated with a WebSocket connection.
The WebSocket client instance to clear timers for.
void
ProtectedconnectConnects all WebSocket connections in the pool
The Websocket server URL.
A promise that resolves when all connections are established.
ProtectedcreateCreates a new WebSocket client instance.
The URL to connect to.
A new WebSocket client instance.
Disconnects from the WebSocket server. If there is no active connection, a warning is logged. Otherwise, all connections in the connection pool are closed gracefully, and a message is logged indicating that the connection has been disconnected.
A Promise that resolves when all connections have been closed.
ProtectedemitProtectedgetRetrieves available WebSocket connections based on the connection mode and readiness. In 'single' mode, returns the first connection in the pool. In 'pool' mode, filters and returns connections that are ready for use.
Optional flag to include non-established WebSocket connections.
An array of available WebSocket connections.
ProtectedgetGets a WebSocket connection from the pool or single connection. If the connection mode is 'single', it returns the first connection in the pool. If the connection mode is 'pool', it returns an available connection from the pool, using a round-robin selection strategy. If no available connections are found, it throws an error.
A boolean indicating whether to allow connections that are not established.
The selected WebSocket connection.
ProtectedgetReturns the URL to use when reconnecting. Derived classes should override this to provide dynamic URLs.
The URL originally passed during the first connection.
The WebSocket connection being connected.
The URL to reconnect to.
ProtectedinitInitializes a WebSocket connection.
The Websocket server URL.
Whether this is a connection renewal.
Optionalconnection: WebsocketConnectionAn optional WebSocket connection to use.
The WebSocket connection.
Checks if the WebSocket connection is currently open.
Optionalconnection: WebsocketConnectionAn optional WebSocket connection to check. If not provided, the entire connection pool is checked.
true if the connection is open, false otherwise.
ProtectedisChecks if the provided WebSocket connection is ready for use. A connection is considered ready if it is open, has no pending reconnection, and has not been closed.
The WebSocket connection to check.
An optional flag to allow non-established WebSocket connections.
true if the connection is ready, false otherwise.
ProtectedonProcesses incoming WebSocket messages
The raw message data received
ProtectedonHandles the opening of a WebSocket connection.
The URL of the WebSocket server.
The WebSocket connection being opened.
The WebSocket client instance associated with the old connection.
ProtectedscheduleSchedules a timer for a WebSocket connection and tracks it
WebSocket client instance
Function to execute when timer triggers
Time in milliseconds before callback execution
Timer type ('timeout' or 'interval')
Timer handle
ProtectedsendSends a payload through the WebSocket connection.
Message to send.
Optionalid: stringOptional request identifier.
Whether to return a promise.
Timeout duration in milliseconds.
Optionalconnection: WebsocketConnectionThe WebSocket connection to use.
A promise if promiseBased is true, void otherwise.
Optionalpayload: WebsocketSendMsgOptionsOptionaloptions: WebsocketSendMsgConfig
Cleans up WebSocket connection resources. Removes all listeners and clears any associated timers for the provided WebSocket client.