Client Reference
On This Page
A complete reference for all functions that can be called for the HighNoon client.
init
Initializes a new client instance with the provided options.
Where the return is in the form of:
connectToRoom
Connects the client to a room.
Where the return is in the form of:
getConnectedClients
Returns the number of clients connected to the room.
Where the return is in the form of:
send
Sends a message to the server using webRTC. This function will call JSON.stringify
on the message before sending it.
This function does not return anything.
relay
Relayes a message to all clients connected to the room. This function uses the WebSocket connection to send information, so it should be used sparingly to avoid rate limiting. It does not return anything.
relayTo
Relayes a message to a specific client connected to the room. This function uses the WebSocket connection to send information, so it should be used sparingly to avoid rate limiting. It does not return anything.
on
The on listener can be used to listen to events emitted by the client. These are listed below, with their respective payloads.
Events
serverConnectionEstablished
Emitted when the client has successfully connected to the server. This event has no payload.
relayFromClient
Emitted when a message is received from another client in the room.
Payload:
relayFromServer
Emitted when a message is received from the server.
Payload:
relay
A more generic event that is emitted alongside relayFromClient
and relayFromServer
. This event is emitted when a message is received from either the server or another client.
Payload:
packet
Emitted when a message is received from the WebRTC connection.
Payload:
ClientListUpdated
This event will fire when a new client joins the server. The server will inform all clients of the update list of clients in the room. It will also differentiate between join and leave events, although it is up to you to handle how to display this information.
Payload:
disconnected
Emitted when the client is disconnected from the server. This event has no payload.