summaryrefslogtreecommitdiff
path: root/doc/protocol.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/protocol.md')
-rw-r--r--doc/protocol.md36
1 files changed, 36 insertions, 0 deletions
diff --git a/doc/protocol.md b/doc/protocol.md
new file mode 100644
index 0000000..cd4694e
--- /dev/null
+++ b/doc/protocol.md
@@ -0,0 +1,36 @@
+# Protocol
+
+Default port is 28555 for TCP and UDP transport.
+
+For TCP, packets are concatenated to a stream.
+
+For UDP, game packets are concatenated in groups of at least one to form one UDP
+packet.
+
+## Protocol packets
+
+All packets are preceeded by its length as u32. The next byte indicates the
+type. The following bytes are the parameters.
+
+`Vec<T>` is stored as u32 element count followed by the elements. `Res<T>` is
+used to denote 256-bit resource hash referring to data of type T. `Obj` refers
+128-bit game objects IDs.
+
+```rs
+00 connect(identity: u128)
+ff disconnect()
+01 request_resource(name: Res)
+02 respond_resource(data: Vec<u8>)
+03 add(id: Obj, prefab: Res<Prefab>)
+04 remove(id: Obj)
+05 position(id: Obj, pos: Vec3, rot: Vec3)
+06 pose(id: Obj, params: Vec<f32>)
+07 parent(parent: Obj, child: Obj)
+08 sound(id: Obj, data: Vec<u8>)
+09 prefab_index(res: Res)
+```
+
+## Resources
+
+Resources are reusable things. They are identified by the SHA-256 hash of their
+serialized content. See [resources.md](./resources.md)