Creates an instance of WebSocketClient
.
The main client instance that manages the bot or app's connection.
The WebSocket server host URL (http or https will be converted to ws or wss).
The authorization token used to authenticate with the WebSocket server.
Event handler for the "message" WebSocket event.
This function is called when a message is received from the WebSocket server. If the message is valid JSON, it triggers the client event registration process. Otherwise, it logs the message.
The raw message data received from the WebSocket server.
The
WebSocketClient
class handles the creation and management of a WebSocket connection to a given server. It can send and receive messages, handle errors, and close the connection gracefully.