Class: WSClient

WSClient

Provides methods and properties for interacting with a WSSocket client


Methods


close()

Close the connection to the client.

Since:
  • 0.1 (WAT 2.0)

send(message)

Sends a message to the client.

Messages to/from clients are strings. If it is desirable to transfer objects instead (e.g. when more complex messages need to be sent), JSON.stringify can be used to convert an object to a string. At the client, the object can be recreated using JSON.parse.

Parameters:
Name Type Description
message string

The message to send

Since:
  • 0.1 (WAT 2.0)
Returns:

Indicates if the transmission was successful.

Type
bool

Events


closed

Emitted when the connection to the client has been closed.

Since:
  • 0.1 (WAT 2.0)

messageReceived

Emitted when a message is received from the client.

Parameters:
Name Type Description
message string

Client message

Since:
  • 0.1 (WAT 2.0)