|
1 | 1 | # Server Protocol |
2 | 2 |
|
| 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 | + |
3 | 6 | ## Version check |
| 7 | + |
4 | 8 | ``` |
5 | 9 | client --- (version <uint32>) --> server (using version) |
6 | 10 | client <-- (version <uint32>) --- server (echo version if supported or 0) |
7 | 11 | ``` |
| 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 | + |
8 | 22 | ## Request cached item |
9 | 23 | ``` |
| 24 | +# Asset binaries |
10 | 25 | client --- 'ga' (id <128bit GUID><128bit HASH>) --> server |
11 | 26 | client <-- '+a' (size <uint64>) (id <128bit GUID><128bit HASH>) + size bytes --- server (found in cache) |
12 | 27 | client <-- '-a' (id <128bit GUID><128bit HASH>) --- server (not found in cache) |
13 | 28 |
|
| 29 | +# Info files |
14 | 30 | client --- 'gi' (id <128bit GUID><128bit HASH>) --> server |
15 | 31 | client <-- '+i' (size <uint64>) (id <128bit GUID><128bit HASH>) + size bytes --- server (found in cache) |
16 | 32 | client <-- '-i' (id <128bit GUID><128bit HASH>) --- server (not found in cache) |
17 | 33 |
|
| 34 | +# Resources |
18 | 35 | client --- 'gr' (id <128bit GUID><128bit HASH>) --> server |
19 | 36 | client <-- '+r' (size <uint64>) (id <128bit GUID><128bit HASH>) + size bytes --- server (found in cache) |
20 | 37 | client <-- '-r' (id <128bit GUID><128bit HASH>) --- server (not found in cache) |
21 | 38 | ``` |
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 | + |
23 | 57 | ``` |
24 | 58 | client --- 'ts' (id <128bit GUID><128bit HASH>) --> server |
25 | 59 | ``` |
26 | 60 |
|
27 | | -## Put cached item |
| 61 | +Then one or more put operations for different kinds of assets |
| 62 | + |
28 | 63 | ``` |
29 | 64 | client --- 'pa' (size <uint64>) + size bytes --> server |
30 | 65 | client --- 'pi' (size <uint64>) + size bytes --> server |
31 | 66 | client --- 'pr' (size <uint64>) + size bytes --> server |
32 | 67 | ``` |
33 | 68 |
|
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 | + |
35 | 71 | ``` |
36 | 72 | client --- 'te' --> server |
37 | 73 | ``` |
| 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 | + |
38 | 84 | ## Quit |
| 85 | + |
39 | 86 | ``` |
40 | 87 | client --- 'q' --> server |
41 | | -``` |
| 88 | +``` |
| 89 | + |
| 90 | +It should be noted that most clients quit by simply closing the connection. |
0 commit comments