mchess uses a simple fixed-length protocol. Every communication between server and client begins with a four-byte keyword, followed by two bytes which represent, in network-order binary, the remaining number of bytes in that particularl communication, including any traling newlines and the like.
In this and the following section, each keyword is followed by a definition, and then a pseudocode prototype of the message that can be paired with each, where 'arbitrary' refers to any (or no) text (usually seen in server-to-client communication), and 'ignored' means the receiving program will accept but discard the message (usually seen in client-to-server stuff).
Sent to a client upon a successful connection to the server.
The generic error keyword.
The generic success keyword.
Confirmation that the client has joined a game.
Generic server-to-client chatter.
Confirmation that the client has started a new game.
Notification that the game to which the client is attached has begun.
A semicolon-deliniated list of all available games, with their players. The message string will be blank if no games are available.
game_number player_name player_name ...;game_number player_name ...
An update that the turn has switched to another player.
Description of the contents of a square on the board. Board coordinates are given as positive integers with (0,0) being the square in the lower left corner.
x_coordinate, y_coordinate piece_letter_or_'E'_for_empty
An update on a player's score.
player's_quadrant_number player's_score player's_name
A piece has been picked up.
A piece has been put down again, with no move made.
The game has ended. This way be from a win, or a player bailing. The message describes which. (This is not sufficient; premature-ending games deserve their own keyword)
Request to join a game.
Request to begin a game.
Request to remove self from a game, but stay connected to the server.
Request to disconnect from the server.
Request to create a new game on the server.
Request to create a new 'bot' player within the current game.
Request to disallow other players from wandering into the current game.
Request to allow other players to join the game freely.
A piece selecion. Can be for selecting or dropping a piece. Board coordinates are given as positive integers with (0,0) being the square in the lower left corner.
Request to abort current move and start over.
A chat message intended for everyone connected to the server.
A chat message intended for everyone in the same game as the player, or the 'waiting area' if the player is not within a game.
A new name for this player.