Dev's NoxDev's Nox
Relay Protocol

Quit

Leave a game instance with handling of the various departure types and notifications to other players.

The Quit message allows clients to leave a game instance in a controlled manner.

It handles the different departure types (voluntary, kick, timeout) and notifies the other players in the instance.

Priority

Critical - This message has the highest priority to guarantee fast resource cleanup.

The Quit message requires the client to be present in the specified instance. Requests for instances where the client is not present will be rejected.


Client → Server Request

Payload Format

[instance_id: byte]
[quit_type: byte]
[reason?: string]

Detailed Structure

TypeNameDescription
byteInstanceIDID of the instance to leave
byteQuitTypeDeparture type
stringReasonDeparture reason (optional)

Quit Types

ValueNameDescription
0x00NormalVoluntary departure of the player
0x01TimeoutDisconnection by timeout
0x02ModerationKickKick by a moderator
0x03VoteKickKick by player vote
0x04ConfigurationErrorConfiguration error
0x05UnknownErrorUnknown error

Payload Example

[0x05]                          // InstanceID = 5
[0x00]                          // QuitType = Normal

Departure with Reason

[0x03]                          // InstanceID = 3
[0x00]                          // QuitType = Normal
[0x0E, "Going to sleep"]        // Reason = "Going to sleep" (14 chars)

Server → Client Response

Payload Format

[instance_id: byte]
[quit_type: byte]
[reason?: string]

Detailed Structure

TypeNameDescription
byteInstanceIDID of the instance left
byteQuitTypeConfirmed departure type
stringReasonDeparture reason (if provided)

Response Example - Success

[0x05]                          // InstanceID = 5
[0x00]                          // QuitType = Normal

Response Example - With Reason

[0x05]                          // InstanceID = 5
[0x00]                          // QuitType = Normal
[0x0E, "Going to sleep"]        // Reason = "Going to sleep"

Response Example - Error

[0x05]                          // InstanceID = 5
[0x05]                          // QuitType = UnknownError
[0x13, "Instance not found"]    // Reason = "Instance not found"

Notification Messages

Leave

When a player leaves, all other players in the instance receive a Leave message with the departure details.

The leaving player also receives Leave messages for all the other players in the instance in order to clean up their local state.


Processing

Server Side

  1. Instance validation: Check that the instance exists
  2. Presence validation: Ensure the client is in the instance
  3. Data reading: Extract the departure type and the reason
  4. Permission validation: Check rights according to the departure type
  5. Player cleanup: Removal from the instance and status update
  6. Notifications: Send Leave messages to the other players
  7. Response: Confirmation to the leaving client

Client Side

  1. Data preparation: Assemble the instance ID and the type
  2. Optional sending: Append the reason if necessary
  3. Notification processing: Handle the received Leave messages
  4. Local cleanup: Removal of the instance data

Notification Filtering

Player Privileges

The departure type in Leave notifications is filtered according to privileges:

  • Regular players: Receive the real type for moderation actions
  • Privileged players: Always receive Normal
  • Initiating moderator: Receives the real type with full details

Moderation Actions

Moderation actions (ModerationKick, VoteKick) include additional information in the Leave message:

  • Moderator/initiator ID
  • Reason for the action (if provided)

Permission Validation

Restricted Departure Types

Some departure types require special permissions:

TypeRequired Condition
ModerationKickThe initiator must be a moderator
VoteKickHandled by the voting system
TimeoutInitiated by the server only
NormalInitiated by the player only

Automatic Rejection

Requests that do not comply with the permissions are automatically rejected without processing.


Special Behaviors

Player Status

Only players with a valid status (PlayerStatus.Ready) trigger notifications to the other players.

Bidirectional Cleanup

When a player leaves:

  1. They receive Leave messages for all the other players
  2. All the other players receive a Leave message for them

Master Server Update

A player's departure immediately triggers a Master Server update to synchronize the instance state.


Error Codes

Instance Errors

  • UnknownError with "Instance not found": The specified instance does not exist
  • UnknownError with "You are not in instance": The client is not in the instance

Permission Errors

Departure attempts with unauthorized types are silently ignored, without an error response.


Disconnection Handling

Automatic Timeout

The server may initiate a Quit with the Timeout type for clients that no longer respond.

Emergency Cleanup

In case of an abrupt disconnection, the server automatically handles the cleanup with an appropriate type.

On this page