blob: 895d1dff7f5b2adcc29aa16956fad74945eba769 (
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
<!--- --------------------------------------------------------------------- -->
# SOLEC protocol specification
* Payload can contain multiple numeric types or binary data in a single frame
* Numeric types are big endian
* Numeric types names are same as in [Go](https://go.dev/ref/spec#Numeric_types)
* See [test payload](#Test) for an example of complex data structure
## Frame
| Type | Description |
|----------|----------------|
| `uint8` | Payload type |
| `uint16` | Payload length |
| `[]any` | Payload |
## Data types
### Numeric types
* `uint8`
* `uint16`
* `uint32`
* `uint64`
### `binary`
| Type | Description |
|--------|----------------|
| uint16 | Data length |
| binary | Data |
### `string`
UTF-8 encoded string encapsulated in `bianry` type.
### `time`
[Unix timestamp](https://en.wikipedia.org/wiki/Unix_time) stored in `uint16`.
Timezone is always UTC.
# Payloads
## Payload prefixes
| Type | Name |
|------|--------------|
| 0x01 | Handshake |
| 0x02 | Ping |
| 0x03 | Pong |
| 0x04 | Message |
| 0xFF | Test |
## Payload types
### Handshake
| Type | Name | Description |
|--------|---------------------|----------------------------------------------------------|
| uint8 | ProtocolVersionMajor | Bumped if changes are incompatible with previous version |
| uint8 | PrococolVersionMinor | Bumber if changes are backwards compatible |
### Ping
Can be send by client or server. Receiver shoudl reply with `Pong`.
### Pong
Reply to `ping`.
| Type | Name | Description |
|--------|------|-------------------------|
| uint64 | Time | Set just before sending |
### Test
Used for testing purposes. Can change at any time.
| Type | Name | Description |
|--------|-------|-------------|
| uint8 | Num1 | |
| time | Time1 | |
| string | Str1 | |
| uint16 | Num2 | |
| binary | Bin1 | |
| uint32 | Num3 | |
| string | Str2 | |
| uint64 | Num4 | |
|