Skip to content

Commit 049baf9

Browse files
committed
Update docs, add G_MESH and P_MESH
1 parent 268787f commit 049baf9

1 file changed

Lines changed: 59 additions & 1 deletion

File tree

delta.md

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ All communication is considered "in-band" between peers. The packet schema is a
2727
"target": "...",
2828
"ttl": 1,
2929
"id": "...",
30-
"method": "..."
30+
"method": "...",
31+
"listener": "...",
3132
}
3233
```
3334

@@ -37,6 +38,7 @@ All communication is considered "in-band" between peers. The packet schema is a
3738
* `target`: **(Required for bridge/relay/broadcasts)** The unique instance ID of the final recipient. This can be a specific peer ID or a broadcast indicator (e.g., `*`).
3839
* `ttl`: **(Required)** Time-To-Live. A number used for bridged/relayed messages. Each peer decrements this value before interpreting the packet. If `ttl` is below 0, the packet will be dropped. The default value is 1.
3940
* `id` & `method`: Optional properties for variable/list synchronization.
41+
* `listener`: Optional property to tag packets and await responses.
4042

4143
-----
4244

@@ -51,13 +53,69 @@ These commands are sent directly between connected peers.
5153
| **`P_MSG`** | A Private Message. The `target` is a specific peer ID. Peers will attempt to bridge the message if not directly connected. |
5254
| `G_VAR`/`P_VAR` | Variable Sync message. Works like `G_MSG`/`P_MSG`. |
5355
| `G_LIST`/`P_LIST`| List Sync message. Works like `G_MSG`/`P_MSG`. |
56+
| `G_MESH` | A global event broadcast. Can be a one-and-done or can await on all recipients. |
57+
| `P_MESH` | A private event broadcast. Can be a one-and-done or can await on the recipient. |
5458
| `NEW_CHAN` | A control message sent to a `target` peer to negotiate a new, named data channel. |
5559
| `PING`/`PONG` | Control messages used for computing RTT. |
5660
| `HANGUP`/`DECLINE`| Voice call control signals sent to a specific `target` peer. |
5761
| `WARNING`/`VIOLATION`| State control messages. `WARNINGS` are safe and user-correctable. `VIOLATION`s will result in mandatory disconnects. |
5862

5963
#### Packet-specific syntax
6064

65+
##### **`G_MSG`/`P_MSG`
66+
The most common event. Designed for simple messaging or updates.
67+
```js
68+
{
69+
"opcode": "G_MSG" | "P_MSG",
70+
"payload": ...,
71+
"ttl": 1,
72+
}
73+
```
74+
75+
##### **`G_VAR`/`P_VAR`
76+
Used in the Sync plugin to synchronize global/local variables. `payload` can be any serializable type, `id` must be a string, and they need to be unique, and they need to be unique.
77+
```js
78+
{
79+
"opcode": "G_VAR" | "P_VAR",
80+
"payload": ...,
81+
"id": string, // network tag
82+
"ttl": 1,
83+
}
84+
```
85+
86+
##### **`G_LIST`/`P_LIST`
87+
Used in the Sync plugin to synchronize global/local lists. `payload` can be a single instance (or an array) of serializable type(s) `id` must be a string, and they need to be unique. `method` is mandatory.
88+
```js
89+
{
90+
"opcode": "G_LIST" | "P_LIST",
91+
"payload": ...,
92+
"method": 'reset' | 'set' | 'update' | 'replace',
93+
"id": string, // network tag
94+
"ttl": 1,
95+
}
96+
```
97+
98+
##### **`G_MESH`/`P_MESH`
99+
Used in the Sync plugin for simple broadcasts. `payload` must be a string. `method` is mandatory. **`G_MESH`/`P_MESH` may only be used on the default data channel.**
100+
```js
101+
{
102+
"opcode": "G_MESH" | "P_MESH",
103+
"payload": string, // broadcast name
104+
"method": '' | 'req',
105+
"ttl": 1,
106+
}
107+
```
108+
109+
If a sent `G_MESH`/`P_MESH`'s `method` has an `req`, recipients are expected to reply with the following once all event threads have finished execution.
110+
```js
111+
{
112+
"opcode": "G_MESH" | "P_MESH",
113+
114+
"method": 'ack',
115+
"ttl": 1,
116+
}
117+
```
118+
61119
##### **`NEGOTIATE`**
62120
**Negotiation is mandatory** for all variants of the Delta protocol.
63121
```js

0 commit comments

Comments
 (0)