GAMESRV(4) GAMESRV(4) NAME gamesrv - game server SYNOPSIS games/gamesrv [ -l ] [ -a alg ]... [ -A ] [ addr|mntpoint ] mntpoint/players mntpoint/new mntpoint/n DESCRIPTION Gamesrv serves a file system that allows clients to interact through various types of game engine. Usually, it operates in network mode: it listens for incoming connections on addr (default tcp!*!3242), authenticates them, and serves files to them. If the -A option is given, no authentication takes place, otherwise each alg gives an additional possible encryption or digest algorithm to use on the connection (see ssl(3)). If no alg is specified, none is assumed. The -l option causes the game server to be mounted locally on mntpoint - this can be useful for single player games, or debugging. Once the name-space served by gamesrv is mounted, it serves the following files. All identifiers referred to below are small integers, expressed as decimal ASCII strings. players Reading this file provides updates on players arriving and leaving, games being created and destroyed, and chat messages outside the scope of any game. Reads will block until something of interest happens. Each update holds space separated tokens and is terminated with a newline. A read will return as many updates as will fit into the read buffer. Update messages are as follows: clientid clientid name Identifies the name, name, and the client identi- fier, clientid, of the client reading the players file. join clientid name A client has authenticated as name, and has been allocated identifier clientid. leave clientid The client identified by clientid has terminated connection with the server. Page 1 Plan 9 (printed 12/22/24) GAMESRV(4) GAMESRV(4) gametype clienttype name The server announces the availability of a game named name on the server. The game requires a client of type clienttype to display the game. creategame gameid name clienttype An instance of a game named name has been created; it needs a client of type clienttype, and has been given identifier gameid. deletegame gameid The game identified by gameid has been deleted. joingame gameid clientid playerid name Client clientid (named name) has joined game gameid , and is allocated player id playerid in the game. leavegame gameid playerid name Player playerid (named name) has left gameid. chat clientid msg Client clientid has sent the chat message msg. Writing to the players file causes a chat message to be sent to all other clients reading the players file. All but the first line of the write request is ignored. new Opening new prepares to create a new game. The only message that can be written to a newly opened game is ``create name'', to request a new game named name. The write request draws an error if gamesrv fails to find and load the requisite game engine. If the write suc- ceeds, the game is created, and game updates can be read in the same manner as from the players file. The update messages are as follows: playerid clientid playerid name Identifies the player identifier, playerid, and name, name, of the reader. create objid parentid visibility objtype Create an object, identified by objid, at the end of parentid's children (parentid is -1 for the root object). Visibility is the visibility set of the object (see gamesrv(2)), and objtype is its type. tx srcid dstid start end index Transfer objects from srcid to dstid. Take the objects from the range [start, end) in the chil- dren of srcid, and insert them just before index Page 2 Plan 9 (printed 12/22/24) GAMESRV(4) GAMESRV(4) in dstid. Note that when objects are transferred to an object that conceals its children, and the object is itself visible, the objects will first be transferred to the destination and then deleted; objects transferred out of such an object will first be created and then transferred to their destination. This enables a client to main- tain some knowledge of where an object has been transferred to, even if the object is no longer visible. del parentid start end Delete the range [start, end) of children from the object identified by parentid. Gamesrv guarantees that those objects will themselves not have any children. set objid attr val Set the attribute named attr on object objid to val. vis objid visibility The visibility of object objid has changed to visibility. action Game engines can generate arbitrary messages of their own devising; such messages are specific to particular client types. Note that a given client does not have to interpret all the above messages - different client types have their own conventions. The card client type uses most of the above functionality, for example, whereas a client for the chat engine listed in gamesrv(2) can get away with interpreting only one message, the custom action chat. Writes to the opened game file are interpreted as game actions by the game that has been loaded, and acted on accordingly. Invalid actions will draw a write error. n Once a game has been created, it appears as a numbered file, corresponding to the gameid of the game in ques- tion. Opening this file joins the game; reads and writes work as for the new file, above. A single client cannot join a particular game more than once. A zero-length write to any file causes any reads of that file from the same file descriptor to yield EOF (no bytes). This is necessary to force a hangup under systems such as Windows, where it is not possible to interrupt a kproc blocked on a network read. Page 3 Plan 9 (printed 12/22/24) GAMESRV(4) GAMESRV(4) EXAMPLE The simplest client! mount tcp!somehost.com!3242 /n/remote { echo create chat >[1=0] cat & cat < /dev/cons >[1=0] } <> /n/remote/new SOURCE /appl/cmd/games/gamesrv.b SEE ALSO gamesrv(2) Page 4 Plan 9 (printed 12/22/24)