WebSocket class
The Zyno Bot Addons WebSocket class extends the NodeJS built-in EventEmitter class.
constructor
The constructor of the WebSocket class requires two arguments. The first argument must be an instance of the WS WebSocket class which provides the data for the WebSocket. The second argument must be an instance of the Zyno Bot Addons WebSocketHandler class which handles the WebSockets.
Properties
id
A randomly generated unique id to identify the WebSocket.
Functions
send
Send a response to the client side of the WebSocket.
Argument | Description |
---|---|
data | A string or instance of the Buffer class which defines the data you'd like to send to the client side of the WebSocket. |
close
Closes the connection between the server and the client side of the websocket.
Events
Event | Description | Arguments |
---|---|---|
message | Gets emitted when the client side of the WebSocket sends a message to the server side. | string |
close | Gets emitted when the connection between the server and the client side of the websocket gets closed. | None |
Last updated