Proposed Communication Protocol =============================================================================== Proposed Version: 3.0 Date: March 5, 2003 Originator: FireAnts (Graham Nasby & Matt Vandenbusshe), Revisions (2.0->2.1): Graham Nasby, Mark Patterson, Mike deRidder, Roderick Oliver, Jesse Miller (2.1->3.0): Graham Nasby ------------------------------------------------------------------------------- 2.0->2.1 - Naming convention: All classes used to send data to and from the server will begin with "net" followed by the object name - Nest Size: The nest will only take up one tile on the map - Rounds per second: 1 Round will occur everysecond. 2.1->3.0 - took definition of object files out of this document - refer to the individual Java files now - all numeric encodings are now stored in the netConstants.java file - added end of game description - added map send/receive handshaking ___________________________________Objects_____________________________________ ------------------------------------------------------------------------------- Tile Object ************************************************* ** Object sent from server to client indicating what specific tiles ** look like see netTileObj.java Return Action Object ************************************************* ** Sent from server to client to indicate what the clients ** ants are doing and what surronding oppent ants are doing ** also used to say that an ant has died see netReturnAction.java Action Object ************************************************* ** numeric ant command sent from client to server ** indicates what the user would like an ant to do see netActionObj.java Game Options Object ************************************************* ** Game Options sent by the 'host' or 'admin' before ** the game starts to set passwords, number of players ** etc.. see netGameOptions.java Start Object ************************************************* see netStartObj.java Message Object ************************************************* see netMsgObj.java Map Object ************************************************* ** The Map object is used to send custom maps ** to and from the server. Maps can be of anysize ** and any dimension less than 250X250 see netMapObj.java _____________________________Handshaking sequence______________________________ ------------------------------------------------------------------------------- Notes: All strings not specified otherwise are sent as msgObjects type 3 (system message) User names can only contain [A-Z][a-z][0-9] no spaces or punctuation allowed Connecting to the server: ************************************************* CLIENT SERVER 1. server has listening socket 2. sends open request 3. sends "HELLO" 4. sends msgObject "USER " reply "ERROR" ** user is disconnected from server or reply "CONNECTED" ** user is now connected Commands allowed at all times once connected: ************************************************* A. send "LISTALL" reply "USERLIST , , handle1, handle2,..." ** list all users connected to server B. send "LISTGAME" reply "USERGAME handle1, handle2, ..." ** list only users connected to server and connected to game ** the first handle is the user who owns the game C. send "STATUS" reply "NOGAME" ** no game exists or reply "WAITING" ** currently waiting for game to start or reply "INPROGRESS" ** game is in progress, you are not part of it or reply "PLAYING" ** user is currently playing game D. send "LOGOUT" reply "GOODBYE" ** connection is dropped (no matter what) Commands allowed only before game started: ************************************************* A1. send "JOIN " reply "WAIT" ** now waiting for game to start or reply "FAIL" (A1a send "CANCEL", reply "MENU") ** user stays logged in . . . reply netStartObj object (does not reply with "GAMESTART") ----------------------------OR----------------------------- B1. send "CREATEGAME" reply "OPTIONS" reply "MAPS :x:y, :x:y..." or reply "FAIL" B2. send gameOptions <---------------------contains all options & game map info reply "WAIT" ** now waiting for game to start (B2a send "ADDUSER ") no reply expected ** adds a user to your game (who is currently not on allowed list) (B2b send "FORCESTART" ) (B2c send "CANCEL", reply "MENU") ** user stays logged in ... (does not reply with "GAMESTART") reply netStartObj object Commands to Send Maps to Server (should be done before joining or creating a game) ************************************************* A1. send SENDMAPFILE ** request permission to send map file reply SENDMAP ** okay to send map file OR reply SENDMAP_NO ** not allowed to send map (refused) OR reply SENDMAP_DUP ** map by that name already exists (refused) A2. send netMapObj reply SENDMAP_OK ** map received okay OR reply SENDMAP_ERR ** error, map was not received okay Commands for Client to Receive Maps (should be done before joining or creating a game) ************************************************* A1. send GETMAPFILE reply netMapObj object OR MAPFILEERROR Commands Allowed once game started: ************************************************* A. send "LISTPLAYING" reply "USERPLAYING handle1, handle2, ..." ** the first handle is listed is the owner of the game B. send "RESIGN" reply "RESIGNED" and reply msgObject, type=1 (endgame) ** user stays logged in (goes back to main menu) C. send "AREYOUTHERE" reply "ALIVE" D. no send receive Tile Object E. no send reply netReturnAction object ** tells client of an ant they can see ** including AntID, team number, positions, status, etc. OR reply netReturnAction object **return with Ant ID with status DEAD ** see netConstants.java F. no send receive MESSAGE G. send MESSAGE no reply required (server will eventually broadcast it out to other players) H. send "KICK " reply "OK" receive Tile Object or reply "FAIL" ** command can only be sent by owner of game I. send "UPDATE" reply TileObject ** forces server to send an update of all tiles J. send "GETCMDLIST" reply "COMMANDS ::, ::, ..." ** text is title of command, ** the number is the identifier used for sending to server ** is the ant type this individual command applies to K. send Action Object no reply (server will eventually send back a Tile Object) ** proper command or no reply, or send ERROR ** invalid command L. send TERMINATE reply "TERMINATED" ** send if we loose contact with server ** connection to server is assumed dropped. M. no send reply ENDOFGAME ** status is either "winner", "loser", or "resigned" (ways to send error messages) N(a). no send reply ERROR N(b). send ERROR no reply =====================================END=======================================