Protected
cleanupThe WebSocket client to clean up.
void
Protected
connectConnects all WebSocket connections in the pool
The Websocket server URL.
A promise that resolves when all connections are established.
Protected
createCreates 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.
Protected
emitProtected
getRetrieves 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.
Protected
getGets 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.
Protected
getReturns 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.
Protected
initInitializes a WebSocket connection.
The Websocket server URL.
Whether this is a connection renewal.
Optional
connection: WebsocketConnectionAn optional WebSocket connection to use.
The WebSocket connection.
Checks if the WebSocket connection is currently open.
Optional
connection: WebsocketConnectionAn optional WebSocket connection to check. If not provided, the entire connection pool is checked.
true
if the connection is open, false
otherwise.
Protected
isChecks 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.
Protected
onProcesses incoming WebSocket messages
The raw message data received
Protected
onHandles 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.
Protected
sendSends a payload through the WebSocket connection.
Message to send.
Optional
id: stringOptional request identifier.
Whether to return a promise.
Timeout duration in milliseconds.
Optional
connection: WebsocketConnectionThe WebSocket connection to use.
A promise if promiseBased
is true, void otherwise.
Optional
payload: WebsocketSendMsgOptionsOptional
options: WebsocketSendMsgConfig
Cleans up WebSocket connection resources. Removes all listeners and clears any associated timers for the provided WebSocket client.