HSWebSocketConnection
TypeA WebSocket connection to a single client, passed to the callback registered with
server.setWebSocketCallback().
Use send() to push messages to the connected client and close() to end the connection.
Do not instantiate HSWebSocketConnection directly — it is created by the server when a
client performs a WebSocket upgrade.
Properties
Methods
send(message) -> None
Send a text message to the connected WebSocket client.
Declaration
send(message) -> None
Parameters
| Name | Type | Description |
|---|---|---|
| message | string | The text message to send. |
Returns
None
Example
server.setWebSocketCallback('/ws', (event, conn, msg) => {
if (event === 'message') conn.send('Echo: ' + msg)
})
close() -> None
Close the WebSocket connection to the client.
Sends a WebSocket close frame and cancels the underlying TCP connection.
Declaration
close() -> None
Returns
None
Example
conn.close()
destroy() -> None
Destroy this connection object, releasing all resources.
Declaration
destroy() -> None
Returns
None
Example
conn.destroy()