Server Reference
On This Page
A complete reference for all functions that can be called for the HighNoon server.
init
Initializes a new server instance with the provided options.
Where the return is in the form of:
createRoom
Create a new 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:
broadcast
Broadcasts a message to all clients that have established WebRTC connections with the server. This function should be used for gameplay information that needs to be transmitted to all clients. This function does not have a return.
send
Sends a message to a specific client using the WebRTC link. This function should be used for information that needs to be transmitted quickly, or with many packets. This will return a success or error depending on if the specified client was found.
Where the return is in the form of:
relay
Sends a message to all clients connected to the server. This function utilises the WebSocket link to send information, so it should be used for information that does not need to be send quickly, but that must arrive.
relayTo
This function sends a message to a specific client using the WebSocket link. This function should be used for information that does not need to be send quickly, but that must arrive.
Where the return is in the form of:
kickClient
Kicks a client from the server. This function should be used to remove a client from the server, and should be used with caution.
on
The on listener can be used to listen to events emitted by the server. These are listed below, with their respective payloads.
Events
clientConnected
Emitted when a client connects to the server.
Payload:
packet
Emitted when a message is received from any connected client.
Payload:
relay
Emitted when the server receives a message from the client via the WebSocket link.
Payload: