@@ -26,16 +26,20 @@ 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 Event names ` t ` ] ( #3213-event-names-t )
3029 - [ 3.2.2 Heartbeats] ( #322-heartbeats )
31- - [ 3.2.3 Event payload definitions] ( #323-event-payload-definitions )
30+ - [ 3.2.3 Gateway event payload definitions] ( #323-gateway -event-payload-definitions )
3231 - [ 3.2.3.1 "Hello" event] ( #3231-hello-event )
33- - [ 3.2.3.2 Identify] ( #3232-identify )
32+ - [ 3.2.3.2 Identify event ] ( #3232-identify-event )
3433 - [ 3.2.3.3 Service channels] ( #3233-service-channels )
35- - [ 3.2.3 Establishing a connection] ( #323-establishing-a-connection )
36- - [ 3.2.4 Events over REST] ( #324-events-over-rest )
37- - [ 3.3 HTTP] ( #33-http )
38- - [ 3.4 Internet Protocol (IP)] ( #34-internet-protocol-ip )
34+ - [ 3.2.3.4 New session event] ( #3234-new-session-event )
35+ - [ 3.2.3.5 Actor certificate invalidation event] ( #3235-actor-certificate-invalidation-event )
36+ - [ 3.2.3.6 Resume event] ( #3236-resume-event )
37+ - [ 3.2.3.7 Server certificate change event] ( #3237-server-certificate-change-event )
38+ - [ 3.2.3.8 Heartbeat and heartbeat ACK events] ( #3238-heartbeat-and-heartbeat-ack-events )
39+ - [ 3.2.4 Establishing a connection] ( #324-establishing-a-connection )
40+ - [ 3.3 Events over REST] ( #33-events-over-rest )
41+ - [ 3.4 HTTP] ( #34-http )
42+ - [ 3.5 Internet Protocol (IP)] ( #35-internet-protocol-ip )
3943 - [ 4. Federated identity] ( #4-federated-identity )
4044 - [ 4.1 Authentication] ( #41-authentication )
4145 - [ 4.1.1 Authenticating on a foreign server] ( #411-authenticating-on-a-foreign-server )
@@ -238,11 +242,6 @@ on the specific event.
238242| ` n ` | string | [ Namespace] ( #82-namespaces ) context for this payload. |
239243| ` op ` | integer | Gateway Opcode indicating the type of payload. |
240244| ` d ` | JSON value | The event data associated with this payload. |
241- | ` s ` ¹ | ?integer | Sequence number for the event, used for session resumption and heartbeats. |
242- | ` t ` ¹ | ?string | Event name for this payload (only applicable for and present in DISPATCH opcode payloads). |
243-
244- ¹ These fields are only included for payloads received from a server and are ` null ` when ` op `
245- is not equal to ` DISPATCH ` .
246245
247246##### 3.2.1.1 Namespaces ` n `
248247
@@ -271,27 +270,19 @@ The following opcodes are defined by the `core` namespace:
271270| ` 8 ` | Service Channel | Actor Send/Receive | Open or close a service channel. |
272271| ` 9 ` | Service Channel ACK | Actor Receive | Acknowledgement of a service channel event. |
273272
274- ##### 3.2.1.3 Event names ` t `
275-
276- The ` t ` field in a gateway event payload indicates the event name for this payload. Event names
277- are only applicable for and present in ` DISPATCH ` opcode payloads.
278-
279- Event names are strings defined by the namespace context and are used to differentiate between different
280- types of events within the ` DISPATCH ` opcode.
281-
282- String values for event names are to be formatted in ` SCREAMING_SNAKE_CASE ` .
283-
284273#### 3.2.2 Heartbeats
285274
286- Heartbeats are used to keep the WebSocket connection alive. The client sends a heartbeat event to the
287- server with a specified interval, which then responds with an acknowledgement for the heartbeat.
275+ Heartbeats are used to keep the WebSocket connection alive. The client continouusly sends a heartbeat
276+ event to the server with the interval specified in the "Hello" event payload.
277+ The server must acknowledge the heartbeat event by sending a heartbeat ACK event back to the client.
278+
288279Servers must account for the time it takes for the client to send the heartbeat event. Before closing
289280a connection due to a missed heartbeat, the server should request a heartbeat event from the client
290281by sending a heartbeat event to the client.
291282
292- The ` d ` payload for a heartbeat event is an empty object ` {} ` .
283+ The structure of the heartbeat and heartbeat ACK events are described in [ section 3.2.3.8 ] ( #3238-heartbeat-and-heartbeat-ack-events ) .
293284
294- #### 3.2.3 Event payload definitions
285+ #### 3.2.3 Gateway event payload definitions
295286
296287##### 3.2.3.1 "Hello" event
297288
@@ -311,7 +302,7 @@ in milliseconds at which the client should send heartbeat events to the server.
311302| -------------------- | ------ | ---------------------------------------------------------------------------------------- |
312303| ` heartbeat_interval ` | uint32 | Interval in milliseconds at which the client should send heartbeat events to the server. |
313304
314- ##### 3.2.3.2 Identify
305+ ##### 3.2.3.2 Identify event
315306
316307The "identify" event is sent by the client to the server to let the server know which actor the
317308client is.
@@ -369,11 +360,71 @@ was successful or not.
369360If a successful subscription to a service channel is acknowledged, all further events and logic
370361is defined by the service's specification.
371362
372- #### 3.2.3 Establishing a connection
363+ ##### 3.2.3.4 New session event
364+
365+ The "New Session" event is sent by the server to all sessions except the new one. The ` d ` payload
366+ of this event contains the ASCII-PEM encoded ID-Cert of the new session. You can find more information
367+ about the new session mechanism in [ section 4.3] ( #43-protection-against-misuse-by-malicious-home-servers ) .
368+
369+ ``` json
370+ {
371+ "n" : " core" ,
372+ "op" : 3 ,
373+ "d" : {
374+ "cert" : " -----BEGIN CERTIFICATE-----\n MIIBIjANB..."
375+ }
376+ }
377+ ```
378+
379+ ##### 3.2.3.5 Actor certificate invalidation event
380+
381+ TODO
382+
383+ ##### 3.2.3.6 Resume event
384+
385+ TODO
386+
387+ ##### 3.2.3.7 Server certificate change event
388+
389+ The server certificate change event notifies clients about a new server ID-Cert. The ` d ` payload
390+ of this event contains the ASCII-PEM encoded ID-Cert of the server.
391+
392+ ``` json
393+ {
394+ "n" : " core" ,
395+ "op" : 6 ,
396+ "d" : {
397+ "cert" : " -----BEGIN CERTIFICATE-----\n MIIBIjANB..."
398+ }
399+ }
400+ ```
401+
402+ ##### 3.2.3.8 Heartbeat and heartbeat ACK events
403+
404+ The heartbeat event is sent by the client to the server to keep the WebSocket connection alive.
405+ The payload for both the heartbeat and heartbeat ACK events is an empty object ` {} ` .
406+
407+ ``` json
408+ {
409+ "n" : " core" ,
410+ "op" : 0 ,
411+ "d" : {}
412+ }
413+ ```
414+
415+ ``` json
416+ {
417+ "n" : " core" ,
418+ "op" : 7 ,
419+ "d" : {}
420+ }
421+ ```
422+
423+ #### 3.2.4 Establishing a connection
373424
374425TODO
375426
376- #### 3.2.4 Events over REST
427+ #### 3.3 Events over REST
377428
378429For some implementation contexts, a constant WebSocket connection might not be wanted. A client can
379430instead opt to query an API endpoint to receive events, which would normally be sent through the WebSocket
@@ -408,7 +459,7 @@ Polling a REST endpoint is inherently inefficient and therefore should only be d
408459ranging from a few minutes to a few days. If a client requires information more often than that,
409460then a WebSocket connection should be considered.
410461
411- ### 3.3 HTTP
462+ ### 3.4 HTTP
412463
413464HTTP/1.1 is the minimum required version that polyproto servers and clients must implement.
414465Implementing HTTP/2 and HTTP/3 is strongly recommended for all use cases, as both versions of the
@@ -417,7 +468,7 @@ and improving performance the most, especially over lossy networks.
417468
418469Future versions of the polyproto specification may mandate the implementation of HTTP/2.
419470
420- ### 3.4 Internet Protocol (IP)
471+ ### 3.5 Internet Protocol (IP)
421472
422473Support for both versions 4 and 6 of the Internet Protocol (IPv4 and IPv6) is mandatory for
423474polyproto client and server software. Real-world availability of both versions of the Internet
0 commit comments