Upon receiving a client connection, the server will place the
connection
into its own thread and pass it off to a function that handles
clients.
The server will then send a game name and version number as an
S-expression
in the following format:
'(hello game_name version)Currently, the game_name is "blue" and the version is "1.0".
The client should respond in a way that confirms he is able to play on
this
version. Possibly something like:
'(ok game_name version)
After the inital handshake the Server is set up to store a gamestate and respond to the functions evaluated upon it. The server also makes sure to update the clients every time the gamestate changes.
| Function | Parameters | Return Value | Purpose |
| tell-all-except | S-expression, exception | #t on success, #f on failure | sends the given S-expression to everyone except the given exception client |
| ok | game-name, version | #t on success, #f on failure | initial greeting packet |
| add-object | index type x y theta movement rotate color | #t on success, #f on failure | server calls this on the client, adding an object to the client's game state, broadcasts to clients |
| update-object | index type x y theta movement rotate color | #t on success, #f on failure | server calls this on the client, updating an object in the client's game state, broadcasts change to clients |
| remove-object | index | #t on success, #f on failure | removes the given index from the gamestate, broadcasts changes to clients |
| fire | x y theta | #t on success, #f on failure | sever adds a bullet to the gamestate with a timeout, broadcasts change to clients |
| collision | index | #t on success, #f on failure | Removes the given object from the gamestate and respawns it elsewhere, broadcasts change to clients |
| chat | string | #t on success, #f on failure | Server broadcasts a chat command to clients |
| Function | Parameters | Return Value | Purpose |
| hello | game-name, version | #t on success, #f on failure | initial greeting packet, responds with an ok packet |
| add-object | index type x y theta movement rotate color | #t on success, #f on failure | client adds object to the current gamestate |
| update-object | index x y theta movement rotate color | #t on success, #f on failure | client updates the given index with the data given |
| remove-object | index | #t on success, #f on failure | removes the given index from the gamestate |
| error | string | #t on success, #f on failure | Client outputs error to console |