Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Commit e28c0b1

Browse files
Merge pull request #45 from tactileentertainment/better-protocol-description
Docs: Improve protocol description
2 parents 51cfa4f + 708b512 commit e28c0b1

File tree

1 file changed

+53
-4
lines changed

1 file changed

+53
-4
lines changed

protocol.md

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,90 @@
11
# Server Protocol
22

3+
Version and size numbers are sent back end forth in hex-encoding. Eg. the
4+
version is sent as `000000fe` over the wire (and *not* the binary `000\u00fe`).
5+
36
## Version check
7+
48
```
59
client --- (version <uint32>) --> server (using version)
610
client <-- (version <uint32>) --- server (echo version if supported or 0)
711
```
12+
13+
The server reads eight bytes of data from the first package received. If the
14+
package contain less than eight bytes, only those are used. Only exception if
15+
getting a one-byte package, in which case it should wait for the next package
16+
in order go get at least two bytes worth of data.
17+
18+
The only accepted client version is 254 (`0xfe` / `0x000000fe`), to which the
19+
server answers `0x000000fe`. In all other cases the server replies `0x00000000`
20+
and closes the connection.
21+
822
## Request cached item
923
```
24+
# Asset binaries
1025
client --- 'ga' (id <128bit GUID><128bit HASH>) --> server
1126
client <-- '+a' (size <uint64>) (id <128bit GUID><128bit HASH>) + size bytes --- server (found in cache)
1227
client <-- '-a' (id <128bit GUID><128bit HASH>) --- server (not found in cache)
1328
29+
# Info files
1430
client --- 'gi' (id <128bit GUID><128bit HASH>) --> server
1531
client <-- '+i' (size <uint64>) (id <128bit GUID><128bit HASH>) + size bytes --- server (found in cache)
1632
client <-- '-i' (id <128bit GUID><128bit HASH>) --- server (not found in cache)
1733
34+
# Resources
1835
client --- 'gr' (id <128bit GUID><128bit HASH>) --> server
1936
client <-- '+r' (size <uint64>) (id <128bit GUID><128bit HASH>) + size bytes --- server (found in cache)
2037
client <-- '-r' (id <128bit GUID><128bit HASH>) --- server (not found in cache)
2138
```
22-
## Start transaction
39+
40+
Cache miss:
41+
42+
grUUIDUUIDUUIDUUIDHASHHASHHASHHASH # uuid/hash is sent as 32 bytes
43+
-rUUIDUUIDUUIDUUIDHASHHASHHASHHASH # negative response
44+
45+
Cache hit:
46+
47+
grUUIDUUIDUUIDUUIDHASHHASHHASHHASH
48+
+r00000000000000ffUUIDUUIDUUIDUUIDHASHHASHHASHHASH<255 bytes of data>
49+
50+
Note that the size is sent as 16 bytes encoded as hexadecimal
51+
52+
## Putting items
53+
54+
Multiple entries (asset, info and resources) exist for one item in the server,
55+
so they're always uploaded inside a transaction:
56+
2357
```
2458
client --- 'ts' (id <128bit GUID><128bit HASH>) --> server
2559
```
2660

27-
## Put cached item
61+
Then one or more put operations for different kinds of assets
62+
2863
```
2964
client --- 'pa' (size <uint64>) + size bytes --> server
3065
client --- 'pi' (size <uint64>) + size bytes --> server
3166
client --- 'pr' (size <uint64>) + size bytes --> server
3267
```
3368

34-
## End transaction (i.e. rename targets to their final names)
69+
And finally the whole thing is finished of (i.e. rename targets to their final names).
70+
3571
```
3672
client --- 'te' --> server
3773
```
74+
75+
An example transaction could be (newlines added for readability)
76+
77+
ts00000000000000ff00000000000000ee # Start transaction for GUID ff / hash ee (32 bytes in total, raw binary stuff)
78+
pi0000000000000008 # Put eight bytes of info
79+
INFOBLOB # Eight bytes of info
80+
pa0000000000000008 # Put eight bytes of data
81+
DATABLOB # Eight bytes of data
82+
te # End transaction
83+
3884
## Quit
85+
3986
```
4087
client --- 'q' --> server
41-
```
88+
```
89+
90+
It should be noted that most clients quit by simply closing the connection.

0 commit comments

Comments
 (0)