Skip to content
Snippets Groups Projects
Verified Commit 10b90395 authored by David Mehren's avatar David Mehren
Browse files

Add docs

parent baa6c4c4
No related branches found
No related tags found
No related merge requests found
# Error codes
Sometimes you will get error codes from the server.
Here is a small documentation of those error codes.
## ERROR_SPAM
You are spamming the server.
## ERROR_PACKET_OVERFLOW
You are sending more than 1024 bytes to the server.
## ERROR_NO_MOVE
You didnt send a move packet.
## ERROR_MAX_CONNECTIONS
Your ip is already connected. IPv6 may workarounds this but please dont flood the server with connections :(
## ERROR_JOIN_TIMEOUT
You didnt send the join packet.
## ERROR_EXPECTED_JOIN
Instead of join you sent some other packet.
## ERROR_INVALID_USERNAME
You used an invalid username. (e.g. not a string)
## ERROR_USERNAME_TOO_SHORT
Username is too short.
## ERROR_USERNAME_TOO_LONG
Username is too long.
## ERROR_USERNAME_INVALID_SYMBOLS
You used invalid symbols for the username.
## ERROR_INVALID_PASSWORD
You used an invalid password. (e.g. not a string)
## ERROR_PASSWORD_TOO_SHORT
Password is too short.
## ERROR_PASSWORD_TOO_LONG
Password is too long.
## ERROR_NO_PERMISSION
You should not do this :^) (e.g. hijack bots)
## ERROR_WRONG_PASSWORD
Your password was wrong.
## ERROR_ALREADY_CONNECTED
You are already connected with this player.
## WARNING_UNKNOWN_MOVE
You did not send a valid move packet.
## ERROR_DEAD_CANNOT_CHAT
You are dead so shush :^)
## ERROR_INVALID_CHAT_MESSAGE
Something is wrong with your chat message.
## ERROR_UNKNOWN_PACKET
Server does not know what you want :D
# Protocol
The protocol is string based.
Every packet will end with a newline (\n), but the Hackathon wrapper handles them for you.
E.g: `pos|10|50|5`
## Packet structure
The general packet structure looks like this:
\<packet type\>\<...arguments\>
E.g: `game|5|1|2|3`
Where game is the packet type, 5 the first argument, 1 the second, 2 the third and 3 the fourth
## Packet types
### motd
The motd packet is sent by the server when you connect to it.
motd means "Message of the day".
**Name:** motd
**Sender:** Server
**Arguments:**
| # | Type | Description |
|---|--------|------------------------|
| 1 | String | The message of the day |
**Example:** `motd|Hello how are you? :)`
### join
The join packet is the first packet the client has to send to the server when connecting.
Remember the password otherwise you cant use the username again!
**Name:** join
**Sender:** Client
**Arguments:**
| # | Type | Description |
|---|--------|--------------|
| 1 | String | The username |
| 2 | String | The password |
**Example:** `join|Cool Guy|mysupersecret`
### error
The error packet is sent by the server if something went wrong.
**Name:** error
**Sender:** Server
**Arguments:**
| # | Type | Description |
|---|--------|-------------------------------------------------------|
| 1 | String | The error according to [ERRORCODES.md](ERRORCODES.md) |
**Example:** `error|INVALID_USERNAME`
### game
The game packet is sent by the server to inform the client about the new game round.
It contains information about the map size and the current player id.
**Name:** game
**Sender:** Server
**Arguments:**
| # | Type | Description |
|---|--------|-------------------------------|
| 1 | Number | The width of the current map |
| 2 | Number | The height of the current map |
| 3 | Number | The current player id |
**Example:** `game|100|100|5`
### pos
The pos packet is sent by the server to inform the client about a players current position.
**Name:** pos
**Sender:** Server
**Arguments:**
| # | Type | Description |
|---|--------|--------------------------|
| 1 | Number | The player id |
| 2 | Number | x position of the player |
| 3 | Number | y position of the player |
**Example:** `pos|5|3|8`
### player
The player packet is sent by the server to share informations of an player.
**Name:** player
**Sender:** Server
**Arguments:**
| # | Type | Description |
|---|--------|------------------------|
| 1 | Number | The player id |
| 2 | String | The name of the player |
**Example:** `player|3|Coolguy`
### tick
The tick packet is sent by the server after a turn has been done. Its the best to send a move packet after this!
**Name:** tick
**Sender:** Server
**Arguments:** None
**Example:** `tick`
### die
The die packet is sent by the server to inform the client about a players who died.
**Name:** die
**Sender:** Server
**Arguments:**
| # | Type | Description |
|------|--------|---------------|
| 1... | Number | The player id |
**Example (1 dead player):** `die|5`
**Example (4 dead player):** `die|5|8|9|13`
### move
The move packet is sent by the client to decide where to move.
**Name:** move
**Sender:** Client
**Arguments:**
| # | Type | Description |
|---|--------|-------------------------|
| 1 | String | up, right, down or left |
**Example:** `move|up`
### win
The win packet is sent by the server to inform the client they won.
**Name:** win
**Sender:** Server
**Arguments:**
| # | Type | Description |
|---|--------|------------------|
| 1 | Number | amount of wins |
| 2 | Number | amount of losses |
**Example:** `win|1|20`
### lose
The lose packet is sent by the server to inform the client they lost.
**Name:** lose
**Sender:** Server
**Arguments:**
| # | Type | Description |
|---|--------|------------------|
| 1 | Number | amount of wins |
| 2 | Number | amount of losses |
**Example:** `lose|1|20`
# Hackatron Demo Client
This is a simple Java client implementation for the FOSS-AG Hackatron.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment