Correct API

This commit is contained in:
Loic Guegan 2019-05-10 09:19:38 +02:00
parent b35687d51b
commit 7d68338dff
2 changed files with 14 additions and 15 deletions

View file

@ -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",

Binary file not shown.