You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: delta.md
+59-1Lines changed: 59 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,8 @@ All communication is considered "in-band" between peers. The packet schema is a
27
27
"target":"...",
28
28
"ttl":1,
29
29
"id":"...",
30
-
"method":"..."
30
+
"method":"...",
31
+
"listener":"...",
31
32
}
32
33
```
33
34
@@ -37,6 +38,7 @@ All communication is considered "in-band" between peers. The packet schema is a
37
38
*`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., `*`).
38
39
*`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.
39
40
*`id` & `method`: Optional properties for variable/list synchronization.
41
+
*`listener`: Optional property to tag packets and await responses.
40
42
41
43
-----
42
44
@@ -51,13 +53,69 @@ These commands are sent directly between connected peers.
51
53
|**`P_MSG`**| A Private Message. The `target` is a specific peer ID. Peers will attempt to bridge the message if not directly connected. |
52
54
|`G_VAR`/`P_VAR`| Variable Sync message. Works like `G_MSG`/`P_MSG`. |
53
55
|`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. |
54
58
|`NEW_CHAN`| A control message sent to a `target` peer to negotiate a new, named data channel. |
55
59
|`PING`/`PONG`| Control messages used for computing RTT. |
56
60
|`HANGUP`/`DECLINE`| Voice call control signals sent to a specific `target` peer. |
57
61
|`WARNING`/`VIOLATION`| State control messages. `WARNINGS` are safe and user-correctable. `VIOLATION`s will result in mandatory disconnects. |
58
62
59
63
#### Packet-specific syntax
60
64
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
+
61
119
##### **`NEGOTIATE`**
62
120
**Negotiation is mandatory** for all variants of the Delta protocol.
0 commit comments