API Docs

A 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

identifier

string
A unique identifier for this connection (UUID string).

Methods

send(message) -> None

Send a text message to the connected WebSocket client.
send(message) -> None
Name Type Description
message string The text message to send.
None
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.
close() -> None
None
conn.close()

destroy() -> None

Destroy this connection object, releasing all resources.
destroy() -> None
None
conn.destroy()