]> git.cworth.org Git - ttt/blobdiff - PROTOCOL
2005-12-03 Richard D. Worth <richard@theworths.org>
[ttt] / PROTOCOL
index 666379735435cb56aebda1c4aed3be5adfeac89a..4fcec635a468d92e7d491d81c35467ecaa0b8663 100644 (file)
--- a/PROTOCOL
+++ b/PROTOCOL
@@ -31,11 +31,11 @@ Document Conventions
        <response> is one of:
 
        <command> <args>
-       ERROR <message>
+       ERROR <error-code>
 
 1. Requests
 
-1.1 Connection setup
+1.1. Connection setup
 
     The TTTP server has no well defined port; agreement on which port to
     use must be done through some external mechanism.  Once connected,
@@ -47,21 +47,37 @@ Document Conventions
     
     HELO <username> <server-addr> <server-port>
 
-    Possible errors: INVALIDNAME
+    Possible errors: INVALID_NAME
 
 1.2. Global commands
 
-    1.2.1 Listing available users
+    1.2.1. Listing available users
 
        WHO
 
        ->
 
-       WHO <username1> <games1> <username2> <games2> ...
+       WHO <username1> <username2> ...
 
-       lists connected users and the number of games they've won.
+       Lists connected users.
 
-    1.2.2. Message
+       Possible errors: NO_NAME_SET
+
+    1.2.2. STATISTICS
+
+       STATISTICS <username>
+
+       ->
+
+       STATISTICS <username> "
+       TICTACTOE WINS <wins>
+       "
+
+       Lists the statistics for the specified user.
+
+       Possible errors: NO_NAME_SET, NO_USER
+
+    1.2.3. Message
 
        MESSAGE <text>
 
@@ -69,15 +85,27 @@ Document Conventions
        
        MESSAGE
 
-    1.2.3. Help
+       Sends a message to all connected users. The text must be a
+       single token. Use a quoted-string to include spaces in the
+       message text.
+
+       Possible errors: NO_NAME_SET
+
+    1.2.4. Help
 
        HELP { <command> }
 
+       ->
+
+       HELP { <command> } "
+       <overview or detailed help>
+       "
+
        Displays help.  If <command> is provided, displays more
        detailed help on a specific command, otherwise displays an
        overview of all commands.
 
-    1.2.4. Quit
+    1.2.5. Quit
 
        QUIT
 
@@ -85,7 +113,9 @@ Document Conventions
 
        QUIT
 
-    1.2.5. Version
+       Disconnects the client from the server.
+
+    1.2.6. Version
 
        VERSION <client-version-number>
 
@@ -109,7 +139,7 @@ Document Conventions
 
        INVITE
 
-       Possible errors: NOUSER, BUSY
+       Possible errors: NO_USER, BUSY, NO_NAME_SET
 
     1.3.2. Accepting an invitation
 
@@ -119,15 +149,40 @@ Document Conventions
 
        ACCEPT
 
+       Possible errors: NO_USER, NO_NAME_SET
+
+    1.3.3. Retracting an invitiation
+
+       RETRACT <username>
+
+       ->
+
+       RETRACT
+
+       Possible errors: NO_USER, NO_NAME_SET
+
+    1.3.3. Declining an invitation
+
+       DECLINE <username>
+
+       ->
+
+       DECLINE
+
+       Possible errors: NO_USER, NO_NAME_SET
+
 1.4. In-game commands
 
+    <game> is a game id generated by the server and first returned in
+    NOTICE NEWGAME
+
     1.4.1. Get the game contents
     
-       SHOW
+       SHOW <game>
     
        ->
     
-       SHOW <game-board>
+       SHOW <game> <game-board>
     
        <game-board> is a quoted multi-line string containing an
        diagram of the tic-tac-toe board, which is a 3x3 array of
@@ -141,28 +196,28 @@ Document Conventions
     
        For example:
     
-       SHOW "
+       SHOW <game> "
        _|X|O 
         _|X|_
         X|O|O"
     
-       Possible errors: NOTINGAME
+       Possible errors: NO_NAME_SET, NO_GAME, NOT_IN_GAME
     
     1.4.2. Part
     
-       PART
+       PART <game>
     
        ->
     
        PART
     
-       Departs the current game
+       Departs the specified game
 
-       Possible errors: NOTINGAME
+       Possible errors: NO_NAME_SET, NO_GAME, NOT_IN_GAME
     
     1.4.3. Making a move
 
-       MOVE <number>
+       MOVE <game> <number>
     
        ->
     
@@ -171,11 +226,12 @@ Document Conventions
        <number> indicates a number in the tic-tac-toe grid as
        follows:
 
-       1|2|3
-       4|5|6
-       7|8|9
+       0|1|2
+       3|4|5
+       6|7|8
     
-       Possible errors: NOTINGAME, NOTYOURMOVE, NOTGRID
+       Possible errors: NO_NAME_SET, NO_GAME, NOT_IN_GAME,
+       NOT_YOUR_MOVE, NOT_GRID
     
 2. Asynchronous notification.  
 
@@ -203,42 +259,63 @@ Document Conventions
        NOTICE QUIT <username>
     
     2.1.3. Game invitation
+
+       2.1.3.1. Invitation is made
+
+               NOTICE INVITE <username1> <username2>
+
+       2.1.3.2. Invitation is accepted
+
+               NOTICE ACCEPT <username2> <username1>
+
+       2.1.3.3. Invitation is retracted
+
+               NOTICE RETRACT <username1> <username2>
+
+       2.1.3.4. Invitation is declined
+
+               NOTICE DECLINE <username2> <username1>
+
+       The first username listed is the one performing the action.
+
+    2.1.4. New games
+
+       NOTICE NEWGAME <game> <username> <username>
     
-       NOTICE INVITE <username>
-    
-    2.1.4. Terminated games
+       The first username listed will go first.
+
+    2.1.5. Terminated games
     
        NOTICE DISPOSE <game>
     
-    2.1.5. Message
+    2.1.6. Message
 
        NOTICE MESSAGE <username> <text>
 
+       where <text> is a quoted-string. Quotes escaped with '\"'
+
 2.2. Game notices
 
     These notices are sent to all players and watchers in
-    the affected game
-
-    2.2.1. Global game notices
+    the affected game.
 
-       2.2.1.1. New game begins
+    <game> is a game id generated by the server and first returned in
+    NOTICE NEWGAME
 
-           NOTICE NEWGAME <username> <username>
-
-           The first username listed will go first
+    2.2.1. Global game notices
 
-       2.2.1.2. Game over, and winner
+       2.2.1.1. Game over, and winner
 
-           NOTICE GAMEOVER <outcome> <username>
+           NOTICE GAMEOVER <game> <outcome> <username>
 
-           <outcame> is either WON in which case <username> indicates
+           <outcome> is either WON in which case <username> indicates
            the winner or CATSGAME in which case <username> is "".
 
     2.2.2. Move notices
 
        2.2.2.1. Move
        
-           NOTICE MOVE <username> <number>
+           NOTICE MOVE <game> <username> <number>
 
 3. Errors
 
@@ -250,13 +327,16 @@ Document Conventions
 
     3.1.1. No name set
     
-       ERROR NONAMESET
+       ERROR NO_NAME_SET
     
-       'helo' must be sent before any command other than 'quit'.
+       'helo' must be sent before any command other than 'help',
+       'version', 'quit'.
+
+       Possibly returned by: WHO MESSAGE INVITE ACCEPT SHOW PART MOVE
     
     3.1.2. Invalid name
     
-       ERROR INVALIDNAME
+       ERROR INVALID_NAME
     
        All names must be of non-zero length and must be unique.
 
@@ -280,13 +360,13 @@ Document Conventions
     
     3.2.3. Not number
     
-       ERROR NOTNUMBER
+       ERROR NOT_NUMBER
     
        A non-numeric value was supplied where a number was required
        
     3.2.4. Not a grid number
     
-       ERROR NOTGRID
+       ERROR NOT_GRID
     
        The number specified in the command was not a valid grid number
     
@@ -300,7 +380,7 @@ Document Conventions
     
     3.4.1. No such game
        
-       ERROR NOGAME
+       ERROR NO_GAME
        
        A game name was provided that does not exist.
        
@@ -308,7 +388,7 @@ Document Conventions
 
     3.5.1. No such user
     
-       ERROR NOUSER
+       ERROR NO_USER
 
        A user name was provided that does not exist.
 
@@ -318,7 +398,7 @@ Document Conventions
     
        3.6.1.1. Not in game
     
-           ERROR NOTINGAME
+           ERROR NOT_IN_GAME
     
            A game playing command was made, but the user is not a
            particpant of any game.
@@ -327,7 +407,7 @@ Document Conventions
 
        3.6.1.2. Not playing
 
-           ERROR NOTPLAYING
+           ERROR NOT_PLAYING
 
            A command was executed by a watching user that is
            permitted only to players
@@ -336,7 +416,7 @@ Document Conventions
     
        3.6.2.1. Not your turn
 
-           ERROR NOTYOURTURN
+           ERROR NOT_YOUR_TURN
     
            A move was submitted during the other player's turn