Skip to content

Client Server Protocol

Brad Colbert edited this page Jul 13, 2025 · 5 revisions

Here’s a summary and validation of the packet types and flow based on the spec, organized into phases with suggestions where helpful:


🔧 Common Packet Header

  • 4 bytes: timestamp (uint32)

  • 2 bytes: packet_counter (uint16)

  • 1 byte: packet_type (char)

Total header: 7 bytes, precedes every packet.


📡 Phase 1: Connection and Lobby Discovery

Step Type Name Direction Contents
1 'r' Register Client → Server None (maybe platform info later?)
2 'R' Acknowledge Registration Server → Client client_id (uint8)
3 'g' Request Game List Client → Server None
4 'G' Game List Server → Client num_games (uint8), array of 10 game structs:– game_id (uint8)– game_info (uint8: type + lock flag)– description (40 chars)– num_players (uint8)

🎮 Phase 2: Joining and Game Setup

Step Type Name Direction Contents
5 'j' Join Game Client → Server game_id (uint8)
6 'J' Join Acknowledgement Server → Client game_id (uint8), player_number (uint8)
7 'd' Game Data Request Client → Server Could be more specific later
8 't' Tile Data Server → Client data_id (uint8), tile_index (uint16), tile_value, count, total
9 'T' Tile Acknowledgement Client → Server data_id (uint8)

🚀 Phase 3: Game Start and Runtime

Step Type Name Direction Contents
10 'b' Begin Game Server → Client Initial player position, orientation
11 'p' (suggested) Player State Client → Server Position, rotation, input flags
12 'q' Quit Client → Server Optional: reason

🧠 Suggestions and Notes

  • Reliable Acks: Capital letters are used as ack packets ('T' for 't'), which is very readable and easy to debug.

  • Unifying acks: May consider an optional common ack packet with a type like 'A' and a field for “acknowledging type” and data_id, if we want to avoid defining too many single-purpose types.

  • Extensibility: Consider reserving a few type letters for future use. Avoid overloading the same type (e.g., 'a') unless context is always unambiguous.


image

Clone this wiki locally