summaryrefslogtreecommitdiffstats
path: root/PROTOCOL.md
diff options
context:
space:
mode:
authorbt <bt@rctt.net>2026-03-09 01:11:13 +0100
committerbt <bt@rctt.net>2026-03-09 22:52:52 +0100
commit077dde28324f42b96239075ada289a58197dc951 (patch)
tree4889aee82e8ea8efeeb141f2a98aeb089fff1798 /PROTOCOL.md
parentcfcb226d3834c00414f4aa57b8f94060b45bb072 (diff)
downloadsolec-077dde28324f42b96239075ada289a58197dc951.tar.gz
solec-077dde28324f42b96239075ada289a58197dc951.zip
Improve protocol format
Diffstat (limited to 'PROTOCOL.md')
-rw-r--r--PROTOCOL.md96
1 files changed, 71 insertions, 25 deletions
diff --git a/PROTOCOL.md b/PROTOCOL.md
index b481a0e..895d1df 100644
--- a/PROTOCOL.md
+++ b/PROTOCOL.md
@@ -1,45 +1,91 @@
+<!--- --------------------------------------------------------------------- -->
+
# SOLEC protocol specification
-## Data format
+* 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
-Everything is big endian. `text` is always null terminated UTF-8.
-Every packet starts with `uint8` denoting type of the rest of remaining data.
+## Frame
-## Event types
+| Type | Description |
+|----------|----------------|
+| `uint8` | Payload type |
+| `uint16` | Payload length |
+| `[]any` | Payload |
-| Type | Name |
-|------|-----------|
-| 0x01 | Handshake |
-| 0x02 | Ping |
-| 0x03 | Pong |
-| 0x04 | Message |
-| 0xFF | Test |
-## Events
+## Data types
-### Handshake
+### Numeric types
+
+* `uint8`
+* `uint16`
+* `uint32`
+* `uint64`
+
+### `binary`
+
+| Type | Description |
+|--------|----------------|
+| uint16 | Data length |
+| binary | Data |
+
+### `string`
+
+UTF-8 encoded string encapsulated in `bianry` type.
-Sent after estabilishing TCP connection. First by the client and then by the server.
-If one of the sides uses different protocol version connection should be aborted.
+### `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 | ver | Protocol version |
+| Type | Name | Description |
+|--------|---------------------|----------------------------------------------------------|
+| uint8 | ProtocolVersionMajor | Bumped if changes are incompatible with previous version |
+| uint8 | PrococolVersionMinor | Bumber if changes are backwards compatible |
### Ping
-Empty.
+Can be send by client or server. Receiver shoudl reply with `Pong`.
### Pong
-`time` field contains Unix timestamp generated just before sending the packet.
-Timezone should always be UTC.
+Reply to `ping`.
-| Type | Name | Description |
-|--------|------|------------------|
-| uint64 | time | Unix timestamp |
+| Type | Name | Description |
+|--------|------|-------------------------|
+| uint64 | Time | Set just before sending |
### Test
-Event type reserved for testing. Does not have defined structure. \ No newline at end of file
+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 | |