blob: b6d249e4b2f79e5b848a6778e520a0c2b6a74238 (
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
|
<!--- --------------------------------------------------------------------- -->
# SOLEC protocol specification
## Data format
* Payload can contain multiple numeric types or binary data in a single frame
* Numeric types are big endian
* See [test payload](#Test) for an example of complex data structure
### Frame structure
| Type | Description |
|----------|----------------|
| `uint8` | Payload type |
| `uint16` | Payload length |
| `any` | Payload |
### Special types
#### Strings and binary
Strings and binary data are prefixed wtith 2 bytes denoting their length.
Strings are UTF-8 encoded.
#### Timestamps
Timestamps are stored as `uint64` in [Unix format](https://en.wikipedia.org/wiki/Unix_time).
Timezone is always set to UTC.
### Payloads
All payload types are described in following files:
* [Kaitai Struct](https://git.sr.ht/~rctt/solec/blob/main/solec.ksy)
* [SVG graph](https://git.sr.ht/~rctt/solec/blob/main/solec.svg)
## Client-server connection initialization
1. Initialize TCP connection
2. Receive `handshake`
3. Send `hadnshake`
4. Send `auth`
5. Receive `success` or `error`
## Client-server messaging
After successfull auth server will listen for payloads of `message` type.
Sending different payload will result in error and connection will be closed
by the server.
Message consist of following fields:
* Source - address of the user sending a message
* Target - address of channel or user receiving a message
* Timestamp - set by user sending a message, UTC timezone
* Content - UTF-8 string
## Addresses
Source and target addresses are similair to e-mail addresses. There are two
parts separated by `@` where second part is address of the server where
specific user or channel is registered on.
Target addresses is set to user that created specific message. Messaegs can be
relayed between servers so it's necessary to keep that info as part of the
message.
Channel addresses always starts from `#` to distinct them from user addresses.
Because of that user address cannot start from this character.
Channels can be grouped in a hierarchy. Levels of channels hierarchy are
separated by `.`.
`*` is special address reserved for broadcast messages send by the server
administrator.
| Type | Address |
|-----------|----------------------|
| user | user@example.org |
| channel | #channel@example.org |
| broadcast | *@example.org |
## Channels hierarchy
Channels can be groupped into a hierarchy. Channels hierarchy can be used to
simplify moderation and management.
|