Relay Protocol
Handshake
Mandatory first exchange between client and server to establish protocol compatibility.
The Handshake message is the mandatory first exchange between a client and the Relay server.
It establishes protocol compatibility and exchanges the basic connection information.
Priority
Critical - This message has the highest priority and must be processed immediately.
Client Request → Server
Payload Format
[protocol: ushort]
[engine: string]
[platform: string]Detailed Structure
| Type | Name | Description |
|---|---|---|
| ushort | Protocol | Protocol version (currently 1) |
| string | Engine | Engine name (e.g. "unity", "unreal") in lowercase |
| string | Platform | Platform (e.g. "windows", "android") in lowercase |
Payload Example
[0x00, 0x01] // Protocol = 1
[0x05, "unity"] // Engine = "unity" (5 chars)
[0x07, "windows"] // Platform = "windows" (7 chars)Server Response → Client
Packet Format
[protocol: ushort]
[client_id: ushort]
[client_ip: 4 bytes]
[client_port: ushort]
[flags: byte]
(IsOffline in flags ? [master_addr: string])
[ushort] Max Packet Size
[ushort] Connection Timeout
[ushort] Keep Alive Interval
[ushort] Segmentation TimeoutDetailed Structure
| Type | Name | Description |
|---|---|---|
| ushort | Protocol | Confirmed protocol version |
| ushort | ClientID | Unique ID assigned to the client |
| byte[4] | IPAddress | Client IP address as seen by the server |
| ushort | Port | Client port |
| byte | Flags | Handshake state flags |
| string | MasterAddr | Master Server address (conditional) |
| ushort | MaxPacketSize | Maximum packet size (1024) |
| ushort | Timeout | Connection timeout (15 sec) |
| ushort | KeepAlive | Keep-alive interval (5 sec) |
| ushort | SegmentationTimeout | Timeout for segmentation sessions (30 sec) |
Handshake Flags
| Value | Name | Description |
|---|---|---|
| 0x00 | None | Normal operation |
| 0x01 | IsOffline | Server in offline mode (no Master Server) |
Response Example
[0x00, 0x01] // Protocol = 1
[0x00, 0x42] // ClientID = 66
[0xC0, 0xA8, 0x01, 0x10] // IP = 192.168.1.16
[0x9C, 0x40] // Port = 40000
[0x00] // Flags = None
[0x0A, "master.nox"] // MasterAddr = "master.nox"
[0x04, 0x00] // MaxPacketSize = 1024
[0x00, 0x0F] // Timeout = 15
[0x00, 0x05] // KeepAlive = 5
[0x00, 0x1E] // SegmentationTimeout = 30Processing
Server Side
- Protocol validation: Version check
- ID assignment: Assignment of a unique ID to the client
- IP detection: Extraction of the client address
- Flags configuration: According to the server state
- Response sending: With all connection parameters
Client Side
- Parameter reception: Local configuration according to the response
- Network configuration: Adjustment according to MaxPacketSize and timeouts
Error Codes
Protocol Incompatibility
If the protocol version does not match or is incompatible, the server sends a Disconnect packet immediately after the Handshake.