added some basic network protocol definitions
This commit is contained in:
parent
b3a02801db
commit
afb0fa4865
2 changed files with 52 additions and 2 deletions
50
README.md
50
README.md
|
@ -1,3 +1,53 @@
|
|||
# Connect Four
|
||||
|
||||
A simple version of the popular game "connect four" written in Java.
|
||||
|
||||
## API docs
|
||||
### SOCKET API
|
||||
#### Basic structure
|
||||
A command consists of a json encoded string of type object which starts with ```<message>``` and ends with ```</message>```.
|
||||
It contains:
|
||||
- id (int): some number, the response will contain the same number
|
||||
- header (int): the actual command to execute
|
||||
- data (mixed): data that has to be passed with the command
|
||||
|
||||
A response consists of a json encoded string of type object which starts with ```<message>``` and ends with ```</message>```.
|
||||
It contains:
|
||||
- id (int): id of the command
|
||||
- header (int): return code of the command (see later)
|
||||
- data (midex): returned data of the command
|
||||
|
||||
#### Return codes
|
||||
The return codes are mostly identical with the HTTP standard codes.
|
||||
However there are some additional ones as well:
|
||||
|
||||
#### Enums
|
||||
Some enumeration types
|
||||
- PlateType
|
||||
- 0: X
|
||||
- 1: O
|
||||
|
||||
#### Commands
|
||||
- Confirm game start
|
||||
- command: 1
|
||||
- requestdata:
|
||||
- type: null
|
||||
- responsedata:
|
||||
- type: object
|
||||
- def:
|
||||
- 'player'
|
||||
- type: PlateType
|
||||
- desc: the plate type the client will use
|
||||
- Insert a plate
|
||||
- command: 100
|
||||
- requestdata:
|
||||
- type: int
|
||||
- decs: index of column to insert plate
|
||||
- replydata:
|
||||
- type: string
|
||||
- def:
|
||||
- 'ok': plate was inserted
|
||||
- 'err': plate was not inserted (either index out of range or clumn full)
|
||||
- 'X': insertion resulted in the winning of PlateType X
|
||||
- 'O': insertion resulted in the winning of PlateType O
|
||||
|
||||
|
|
|
@ -284,7 +284,7 @@ public class GameBoard extends JPanel {
|
|||
}
|
||||
|
||||
/**
|
||||
* Override paint function to rescale all caontainers on every repaint
|
||||
* Override paint function to rescale all containers on every repaint
|
||||
*/
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
|
|
Reference in a new issue