blob: a014d17ed030c40286607d7256efd5b641495eb5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# Hurry Curry! protocol
The protocol schema is defined in [`protocol.ts`](./test-client/protocol.ts)
1. Connect to the server via WebSocket and send/receive JSON in text messages.
2. Wait for `version` packet and check version compatibiliy (see below).
3. The server will send the current game data and state, then finishes with
`set_ingame(state=true)`
4. Send `join` with your username, the server will confirm your join with
`joined`.
5. Run the game loop
- Send a `keepalive` packet every 1000ms.
- Send your position via `movement` every 20ms - 40ms.
- Send `interact` when the player interacts with a tile.
- Receive packets
6. The Game ends. The server will remove all players and tiles, then send
`set_ingame(state=false)`. Then continue at step 4.
## Ports
- 443: All uses with TLS
- 27032: Game Server Websocket
- 27033: Registry API HTTP / Local dicovery service
- 27034: Lobby Server Websocket
- 27035: Map Editor Server Websocket
<!-- ## Binary Protocol
Servers might also support the binary protocol. It uses
[Bincode](https://github.com/bincode-org/bincode) to encode packets. If a server
advertises bincode support with the `init` packet, you are free to use the
binary protocol. By default the server will send JSON. For every packet you
send, you can choose between bincode and JSON. After a client sent the first
Bincode packet, the server might start to reply using Bincode aswell. Bincoded
packets are sent with WebSocket "Binary" messages. -->
## Protocol Versioning
The `init` packet sends minor and major version numbers of the protocol is use
by the server. These are to be interpreted according to
[SemVer](https://semver.org/) for the JSON protocol.
## Movement
Movement is handled server-side but should be predicted by client for better
latency. For this reason it implemented three times:
- In GDscript (for the Godot client):
[controllable_player.gd](./client/player/controllable_player.gd)
- In Rust (for server and standalone bots):
[movement.rs](./server/protocol/src/movement.rs)
- In TypeScript (for test-client): [movement.ts](./test-client/movement.ts)
## Limits
The server currently enforces the following network limits:
- Server inbound json packets are at most 8196 bytes in size
- Server inbound binary packets are at most 4096 bytes in size
- Player names are no longer than 32 characters
- Player names are no longer than 64 bytes
|