(Back to the jmac Martian Chess page)
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.
arbitrary
The generic error keyword.
arbitrary
The generic success keyword.
abitrary
Confirmation that the client has joined a game.
game_number arbitrary
Generic server-to-client chatter.
arbitrary
Confirmation that the client has started a new game.
new_game_number arbitrary
Notification that the game to which the client is attached has begun.
arbitrary
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.
player_name
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.
x_coordinate y_coordinate
A piece has been put down again, with no move made.
x_coordinate y_coordinate
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)
arbitrary
Request to join a game.
game_number player_name
Request to begin a game.
ignored
Request to remove self from a game, but stay connected to the server.
ignored
Request to disconnect from the server.
ignored
Request to create a new game on the server.
player_name
Request to create a new 'bot' player within the current game.
ignored
Request to disallow other players from wandering into the current game.
ignored
Request to allow other players to join the game freely.
ignored
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.
x_coordinate, y_coordinate
Request to abort current move and start over.
ignored
A chat message intended for everyone connected to the server.
arbitrary
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.
arbitrary
A new name for this player.
player_name