Events
Using the net_event function, you can register a callback for an event.
Detecting a network disconnection#
You can register an event to detect a disconnection and automatically try to reconnect the player.
Handling errors#
To handle errors, you can register a callback for the wsnet_evt.error event.
Error Codes: no_error, command_not_found, player_not_found, lobby_not_found, unauthorized, wrong_password, max_lobby_players, input_validation_failed, already_in_lobby, server_error, callback_not_found, incorrect_type
Lobby events#
Receive a response from the server saying if your lobby has been created or not.
Receive a response from the server saying if your successfully joined a lobby.
Receive a response from the server with the lobbies list (stored in global.net_lobbies).
Receive a response from the server saying if you left the lobby successfully.
Receive a response from the server saying if the Allow Join flag has been updated successfully.
Receive a response from the server saying if the max number of players that can join has been updated successfully.
Receive a response from the server saying if the lobby password has been updated successfully.
Receive a response from the server saying if the lobby has been transfered to another player successfully.
Receive a response from the server saying if the player has been unbanned successfully.
Receive a response from the server with the banned player list (Each player is associated to a short hash, that can be used to unban them)
Players events#
Receive a message from the server saying that a new player joined the lobby.
Receive a message from the server saying that a player left the lobby.
Receive a message from the server saying that a player has been kicked or banned from your lobby.
Receive a message from the server saying that a player changed username.