diff options
| author | Loic Guegan <manzerberdes@gmx.com> | 2019-05-10 09:19:38 +0200 |
|---|---|---|
| committer | Loic Guegan <manzerberdes@gmx.com> | 2019-05-10 09:19:38 +0200 |
| commit | 7d68338dff51402e19fbcf35790d7e4fc6448a07 (patch) | |
| tree | af77f55a4533e369763e305cd6c5f03d8482b85b | |
| parent | b35687d51b56c2aafdb6ec5243c53d33b749a933 (diff) | |
Correct API
| -rw-r--r-- | doc/api.org | 29 | ||||
| -rw-r--r-- | doc/api.pdf | bin | 122183 -> 122602 bytes |
2 files changed, 14 insertions, 15 deletions
diff --git a/doc/api.org b/doc/api.org index bfabd40..e5da347 100644 --- a/doc/api.org +++ b/doc/api.org @@ -4,25 +4,24 @@ #+LATEX_HEADER: \usepackage{fullpage} * General Description - - All transmissions will be based on TCP because: - - Packet length are not fixed - - Packet ordering is important - - All TCP stream from *client to server* will: - - Contain plain json data - - Be terminated by a "#EOF" line (in order for the server to detect the end of the request - - All TCP stream from *server to client* will contains plai json data (connection will be closed by the server - so there is no need of "#EOF". + - All transmissions will be based on TCP since: + - Packet length are not fixed (large variance depending on the snake size and food) + - Packet ordering is important (inverted request can compromise gameplay) + - All TCP streams from *client to server* will: + - Contain _plain json data_ + - Be terminated by an "#EOF" line (in order for the server to detect the end of the client request) + - All TCP stream from *server to client* will contains _plain json data_ (connection will be closed by the server + so, there is no need of "#EOF"). * Communications ** Initialisation - 1. Server wait for a client - 2. Client can send: + 1. Client sent: #+BEGIN_SRC json { "type": "new-game" } #EOF #+END_SRC - 3. Server can reply: + 2. Server can reply: #+BEGIN_SRC json { "type": "state", @@ -34,7 +33,7 @@ #+END_SRC ** Gameplay *** Change Direction - 1. When client is playing a game it can ask to the server to change snake direction: + 1. When client is playing a game, it can ask the server to change snake direction: #+BEGIN_SRC json { "type": "update", @@ -43,7 +42,7 @@ } #EOF #+END_SRC - 2. Server can reply + 2. Then, server can reply: #+BEGIN_SRC json { "type": "state", @@ -54,7 +53,7 @@ } #+END_SRC *** Refresh Screen - 1. When no key are press (the snake is simply going straigth forward). So, client can send: + 1. When no key are pressed (the snake is simply going forward). So, client can send: #+BEGIN_SRC json { "type": "update", @@ -74,7 +73,7 @@ } #+END_SRC *** End Game - - When game is over server will send the following state message (switch game-over to true): + - When game is over, server will send the following state message (switch "game-over" to true): #+BEGIN_SRC json { "type": "state", diff --git a/doc/api.pdf b/doc/api.pdf Binary files differindex 902dc6b..34d125b 100644 --- a/doc/api.pdf +++ b/doc/api.pdf |
