Communication

Client to server messages always contain a 2 byte “size” field, a 4 byte “player_id” field, 2 byte “message_type” field. The server uses this on the empty payload CLIENT_JOIN message to determine if the client is a playing client (as opposed to spectating).

  1. Client: Sends CLIENT_JOIN.

  2. Server: Sends ACKNOWLEDGE_JOIN.

  3. Server: When the last playing client joins, the server sends ACKNOWLEDGE_JOIN to that last client and then broadcasts PLAYERS and BOARD messages. Note at this point the game begins.

  4. Client: Player 1 will place a mouse on their client and then send the MOUSE_PLACED message.

  5. Server: BOARD message is broadcast each time a MOUSE_PLACED message comes in. Clients can figure out for themselves when the game has actually started.

  6. Client: Player will move and send the MOUSE_MOVED message.

  7. Server: BOARD message is broadcast.

  8. Server: Once game is finished, server broadcasts GAME_OVER message with the player scores.

In the future, Server will also send an INVALID_REQUEST message as appropriate.