Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.

Commit 6247bdd

Browse files
committed
think about sequence numbers and resume events
1 parent a89e2ce commit 6247bdd

File tree

1 file changed

+26
-6
lines changed
  • docs/Protocol Specifications

1 file changed

+26
-6
lines changed

docs/Protocol Specifications/core.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ weight: 0
2626
- [3.2.1 Gateway Event Payloads](#321-gateway-event-payloads)
2727
- [3.2.1.1 Namespaces `n`](#3211-namespaces-n)
2828
- [3.2.1.2 Opcodes `op`](#3212-opcodes-op)
29+
- [3.2.1.3 Sequence numbers `s`](#3213-sequence-numbers-s)
2930
- [3.2.2 Heartbeats](#322-heartbeats)
3031
- [3.2.3 Gateway event payload definitions](#323-gateway-event-payload-definitions)
3132
- [3.2.3.1 "Hello" event](#3231-hello-event)
@@ -237,11 +238,12 @@ end
237238
Gateway event payloads share a general structure, though the content of the `d` field varies depending
238239
on the specific event.
239240

240-
| Field | Type | Description |
241-
| ----- | ---------- | ------------------------------------------------------------------------------------------ |
242-
| `n` | string | [Namespace](#82-namespaces) context for this payload. |
243-
| `op` | integer | Gateway Opcode indicating the type of payload. |
244-
| `d` | JSON value | The event data associated with this payload. |
241+
| Field | Type | Description |
242+
| ----- | ---------- | ------------------------------------------------------------------- |
243+
| `n` | string | [Namespace](#82-namespaces) context for this payload. |
244+
| `op` | uint16 | Gateway Opcode indicating the type of payload. |
245+
| `d` | JSON value | The event data associated with this payload. |
246+
| `s` | uint32 | Sequence number of the event, used for guaranteed, ordered delivery |
245247

246248
##### 3.2.1.1 Namespaces `n`
247249

@@ -264,12 +266,27 @@ The following opcodes are defined by the `core` namespace:
264266
| `2` | Identify | Actor Send | Identify to the server. |
265267
| `3` | New Session | Actor Receive | Received by all sessions except the new one. |
266268
| `4` | Actor Certificate Invalidation | Actor Send/Receive | An actor certificate has been invalidated. Sent *to* server when an actor invalidates one of their certificates. |
267-
| `5` | Resume | Actor Send | Resume a connection. |
269+
| `5` | Resume | Actor Send/Receive | Replay events after re-connecting. |
268270
| `6` | Server Certificate Change | Actor Receive | Received when the server's certificate changed. |
269271
| `7` | Heartbeat ACK | Actor Receive | Acknowledgement of a heartbeat |
270272
| `8` | Service Channel | Actor Send/Receive | Open or close a service channel. |
271273
| `9` | Service Channel ACK | Actor Receive | Acknowledgement of a service channel event. |
272274

275+
##### 3.2.1.3 Sequence numbers `s`
276+
277+
<!-->
278+
TODO
279+
<-->
280+
281+
!!! bug TODO
282+
283+
How are we going to do sequence numbers? Requirements are:
284+
285+
- Guaranteed, ordered delivery of payloads
286+
- Notice delivery gaps, especially when connection stability is flawed
287+
288+
See: https://chatgpt.com/share/678e89ba-aa20-8004-bde7-4a33bab804b9
289+
273290
#### 3.2.2 Heartbeats
274291

275292
Heartbeats are used to keep the WebSocket connection alive. The client continuously sends a heartbeat
@@ -429,6 +446,9 @@ occurs.
429446

430447
##### 3.2.3.6 Resume event
431448

449+
When a client re-connects to a polyproto WebSocket gateway server, the client may send a resume event
450+
to the server instead of identifying.
451+
432452
TODO
433453

434454
##### 3.2.3.7 Server certificate change event

0 commit comments

Comments
 (0)