Sessions
Retrieval of the list of available instances with pagination for navigation.
The Sessions message allows clients to retrieve the list of instances available on the server.
It uses a pagination system to efficiently handle large lists of instances.
Priority
Normal - This message has a normal priority because it is an information lookup.
The Sessions message requires the client to have completed the Handshake. Requests sent before the handshake will be ignored by the server.
Client → Server Request
Payload Format
[pagination: byte]Detailed Structure
| Type | Name | Description |
|---|---|---|
| byte | Pagination | Page number to retrieve (0-based) |
Request Example
[0x00] // Pagination = 0 (first page)Request Example - Next Page
[0x02] // Pagination = 2 (third page)Server → Client Response
Payload Format
[instance_count: byte]
[current_page: byte]
[total_pages: byte]
[instances: Instance[instance_count]]Instance Structure
[flags: uint]
[internal_id: byte]
[master_id: uint]
[current_players: ushort]
[capacity: ushort]Detailed Structure
| Type | Name | Description |
|---|---|---|
| byte | InstanceCount | Number of instances in this page |
| byte | CurrentPage | Number of the current page |
| byte | TotalPages | Total number of available pages |
| uint | Flags | Instance configuration flags |
| byte | InternalID | Internal ID of the instance on this relay |
| uint | MasterID | ID of the instance on the Master Server |
| ushort | CurrentPlayers | Number of currently connected players |
| ushort | Capacity | Maximum capacity of the instance |
Instance Flags
| Value | Name | Description |
|---|---|---|
| 0x01 | IsPublic | Instance publicly visible |
| 0x02 | UsePassword | Password protection |
| 0x04 | UseWhitelist | Whitelist access control |
| 0x08 | AuthorizeBot | Allows bot connections |
| 0x10 | AllowOverload | Allows exceeding the capacity |
Response Example - Page with Instances
[0x02] // InstanceCount = 2
[0x00] // CurrentPage = 0
[0x01] // TotalPages = 1
// Instance 1
[0x00, 0x00, 0x00, 0x01] // Flags = IsPublic
[0x05] // InternalID = 5
[0x00, 0x00, 0x04, 0x2A] // MasterID = 1066
[0x00, 0x08] // CurrentPlayers = 8
[0x00, 0x20] // Capacity = 32
// Instance 2
[0x00, 0x00, 0x00, 0x03] // Flags = IsPublic | UsePassword
[0x03] // InternalID = 3
[0x00, 0x00, 0x05, 0x39] // MasterID = 1337
[0x00, 0x04] // CurrentPlayers = 4
[0x00, 0x10] // Capacity = 16Response Example - Empty Page
[0x00] // InstanceCount = 0
[0x02] // CurrentPage = 2
[0x02] // TotalPages = 2Response Example - Invalid Page
[0x00] // InstanceCount = 0
[0x05] // CurrentPage = 5 (requested)
[0x03] // TotalPages = 3 (maximum available)Pagination System
Automatic Calculation
The server automatically computes the number of pages based on:
- Maximum size:
MaxPacketSize - 2bytes per page - Instance limit: Maximum 255 instances per page (
byte.MaxValue) - Size per instance: About 15 bytes per instance
Page Handling
- Pages 0-based: The first page is
0 - Invalid page: If
pagination >= totalPages, returns an empty page - Dynamic calculation: The number of pages may change between requests
Optimization
The system automatically optimizes the distribution to maximize the use of the available bandwidth.
Processing
Server Side
- State validation: Check that the client has completed the handshake
- Pagination read: Extraction of the requested page number
- Page computation: Dynamic generation of pages according to the packet size
- Page validation: Check that the requested page exists
- Response building: Assembly of the instance data
- Sending: Transmission of the requested page
Client Side
- Request sending: Specification of the desired page
- Response reception: Processing of the instance data
- Pagination handling: Navigation between the available pages
- Interface update: Display of the instances with their statuses
Special Behaviors
Dynamic Pages
The content and the number of pages may change between requests:
- New instances created
- Instances removed
- Change in the number of players
Private Instances
Instances with IsPublic = false are not included in the public sessions list.
Real-Time Data
The returned information reflects the current state:
- Number of connected players
- Status of the instance flags
- Availability of the instances
Integration with Other Messages
Relation with Enter
The Sessions information allows choosing an instance before using Enter:
- InternalID: Used to join the instance
- Flags: Indicate the prerequisites (password, whitelist)
- Capacity: Allows checking availability
Relation with ServerConfig
Changes via ServerConfig immediately affect the data returned by Sessions.
Error Handling
Nonexistent Page
If the requested page does not exist, the server returns:
InstanceCount = 0CurrentPage= requested pageTotalPages= real number of pages
No Instance
If the server has no public instance:
InstanceCount = 0CurrentPage = 0TotalPages = 0
Disconnection Required
Requests before the handshake are silently ignored.
Optimizations
Caching
Clients may cache the Sessions data to:
- Reduce the request frequency
- Improve the interface responsiveness
- Limit the server load
Smart Pagination
Recommended strategies:
- Load the first page immediately
- Preload the following pages if necessary
- Refresh only when a change is detected
Compression
The compact format (15 bytes per instance) allows:
- About 68 instances per 1024-byte packet
- Efficient transmission even with many instances
- Reduced network latency