summaryrefslogtreecommitdiff
path: root/protocol.md
diff options
context:
space:
mode:
Diffstat (limited to 'protocol.md')
-rw-r--r--protocol.md24
1 files changed, 21 insertions, 3 deletions
diff --git a/protocol.md b/protocol.md
index 28626200..956663ba 100644
--- a/protocol.md
+++ b/protocol.md
@@ -20,9 +20,10 @@
The protocol schema is defined in [`protocol.ts`](./test-client/protocol.ts)
-1. Connect to the server via ~~TCP (on port 27031) or~~ WebSocket (on
- port 27032) and send/receive json on individual lines / text messages.
-2. Wait for `init` packet.
+1. Connect to the server via WebSocket (on port 27032 for plain HTTP or 443 with
+ SSL) and send/receive json in WebSocket "Text" messages. The binary protocol
+ uses "Binary" messages and is optional for servers and clients.
+2. Wait for `init` packet and check version compatibiliy (see below).
3. Send the join packet with your username.
4. The server will send the current game state:
- `data` once for setting important look-up tables
@@ -42,6 +43,23 @@ Collisions are handled by the clients. Whenever to players collide the player
with the greater PlayerID is responsible for updating their own momentum and
sending a packet to update that of the other player.
+## 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. The binary protocol can not
+be used if either minor or major version differs.
+
## Movement
Movement is handled mostly client-side. Therefore it is implemented three times: