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
| Type | Name | Description |
|---|---|---|
| byte | InstanceID | ID of the instance to leave |
| byte | QuitType | Departure type |
| string | Reason | Departure reason (optional) |
Quit Types
| Value | Name | Description |
|---|---|---|
| 0x00 | Normal | Voluntary departure of the player |
| 0x01 | Timeout | Disconnection by timeout |
| 0x02 | ModerationKick | Kick by a moderator |
| 0x03 | VoteKick | Kick by player vote |
| 0x04 | ConfigurationError | Configuration error |
| 0x05 | UnknownError | Unknown error |
Payload Example
[0x05] // InstanceID = 5
[0x00] // QuitType = NormalDeparture 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
| Type | Name | Description |
|---|---|---|
| byte | InstanceID | ID of the instance left |
| byte | QuitType | Confirmed departure type |
| string | Reason | Departure reason (if provided) |
Response Example - Success
[0x05] // InstanceID = 5
[0x00] // QuitType = NormalResponse 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
- Instance validation: Check that the instance exists
- Presence validation: Ensure the client is in the instance
- Data reading: Extract the departure type and the reason
- Permission validation: Check rights according to the departure type
- Player cleanup: Removal from the instance and status update
- Notifications: Send Leave messages to the other players
- Response: Confirmation to the leaving client
Client Side
- Data preparation: Assemble the instance ID and the type
- Optional sending: Append the reason if necessary
- Notification processing: Handle the received Leave messages
- 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:
| Type | Required Condition |
|---|---|
| ModerationKick | The initiator must be a moderator |
| VoteKick | Handled by the voting system |
| Timeout | Initiated by the server only |
| Normal | Initiated 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:
- They receive
Leavemessages for all the other players - All the other players receive a
Leavemessage for them
Master Server Update
A player's departure immediately triggers a Master Server update to synchronize the instance state.
Error Codes
Instance Errors
UnknownErrorwith "Instance not found": The specified instance does not existUnknownErrorwith "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.