=============================================================================== monopd API Revision: 0.9.3 Erik Bourget Rob Kaper =============================================================================== Contents 1) Notes i. protocol notes ii. server introduction iii. contact information iv. generally active servers 2) Client->Server Messages 3) Server->Client Messages =============================================================================== 1) Notes =============================================================================== i. protocol notes ----------------- Commands from clients to the monopd server are in the form of a tiny message preceeded by a dot and followed by a newline: .gn Messages from the server to clients are in XML form. An example: All messages are complete and exclusive to the line they are sent on; a message such as should be parsed by clients as five seperate (and all invalid) messages. is thus one valid message. Further example messages in this document will however be wrapped using newlines, for readability. There have been complaints of monopd sending multiple root elements in one "document", but unless there's a bug somewhere, newline seperated messages itself should not contain more than one root element. Please do treat data after a newline as a new document. Most modern network APIs provide methods such as canReadLine() and readLine() which are optimised for this usage. Not all fields of the XML messages are sent on every update; clients are to assume that anything not referred to is either undefined if there has been no previous mention of the attribute, or that it keeps the same value as the last update that included it set it to. These incremental updates decreases the amount of data sent over the network. The encoding of the protocol is UTF-8. ii. server introduction ----------------------- The server identifies itself with an introductory XML message: The client must then complete the handshake by using the "set name" command: .n$1 $1 string Player name. Until this command has been sent, any data the client sends will be ignored. When the handshake is completed the server gives the client some connection info: Each client that connects to the server receives a unique playerid; this will be used as identifier in games and eventually together with the cookie field to support graceful reconnects after timeouts. iii. contact information ------------------------ The monopd team uses the monopd-devel@lists.capsi.com mailinglist as its primary discussion forum. While this documentation ought to be complete and free of errors, there might be inconsistencies, missing entries or other problems you might experience when dealing with the protocol. Please do not hesitate to report any problems or ask for clarification when in doubt. iv. generally active servers --------------------------- A list of available monopd servers is available on http://monopd.unixcode.org/ and can be used by clients to connect to dedicated servers on the Internet. Please read the file README.monopigator from the monopd distribution for more information. =============================================================================== 2) client->server messages =============================================================================== The following is a list of supported client-server messages. $ refers to a value that should be supplied; i.e. for a command .xyz$1, the message .xyz14 would be a valid instance of the command to send to the server. - connection commands .R$1 : reconnect using cookie $1. - game commands .gn$1 : create a new game of optional type $1. monopd defaults to the Atlantic game type. .gl : request a game list. .gj$1 : join game number $1. .gx : exit a game without disconnecting from the monopd server .gk$1 : the player listed as master for a game can use this to kick a player with playerid $1 from a game during configuration, back into the lounge .gu$1 : upgrade spectating player with playerid $1 to a real player. Only the master can do so. .gc$1:$2 : Make changes to the game configuration. $1 is the unique configId from a received configupdate and $2 is the new value for value, which can be string, int or bool depending on the type specificed in the configupdate. .gS$1 : Join game $1 as spectator. - trade commands .Tn$1 : Initiate a trade with player with playerid $1. .Tc$1:$2:$3 : Set target owner of card $2 to player $3 in trade $1. .Te$1:$2:$3 : Set target owner of estate $2 to player $3 in trade $1. .Tm$1:$2:$3:$4 : Player $2 gives $3 an amount of $4 as part of trade $1. .Ta$1:$2 : Accept current (revision $2) terms of trade with tradeid $1. .Ta$1 : Accept current terms of trade with tradeid $1. (WARNING: deprecated. Exists for backwards compatiblity but clients are encouraged to use the above command instead) .Tr$1 : Reject trade $1. - movement commands .r : roll dice for movement .E : end current turn .t$1 : confirm latest player movement to location $1. This is used for clients that animate token movement to let the daemon know when to give money for going across "Go". - debt settling commands .D : declare bankruptcy .p : pay off debts - estate management commands .eb : buy current estate .es$1 : sell estate with estateid $1 to bank .ea : auction current estate .hb$1 : buy a house on estate with estateid $1 .hs$1 : sell a house on estate with estateid $1 .em$1 : toggle mortgage on estate with estateid $1 - auction commands .ab$1:$2 : bid $2 dollars for auction with auctionid $1 - jail commands .jc : use get out of jail free card .jp : pay get out of jail fee .jr : attempt to roll doubles in jail - tax commands (only available when the tax dialog has been initialised) .T$ : pay static tax .T% : pay tax as percentage of assets - player management commands .pi$1 : set player image to $1 - game management commands .gn : start a new game .gl : request a list of open games .gj$1 : join game with gameid $1 .gd$1 : set current game description to $1 .gs : start current game - miscellaneous commands .d : disconnect from server .n : set name .f : request full update =============================================================================== 3) server->client messages =============================================================================== While they won't come like this from the server, I've split some messages onto more than one line for readibility. Each line of messages is enclosed by and . -------------------- Identifies the server, sent upon connection. -------------------- Gives the client a unique identification. -------------------- Used for sending informative messages to clients. Possible types include chat, info, error, standby, and startgame. These are just to display to users and can be ignored as they will always be accompanied by more 'official' messages. For chat messages, playerid and name of the chatting player are sent. --------------------