Skip to content

Commit

Permalink
Merge pull request #137 from ably/presencemap-clarification
Browse files Browse the repository at this point in the history
Spec: add RTP2b1a to clarify edge-case in newness comparison
  • Loading branch information
SimonWoolf authored Apr 5, 2023
2 parents d745ee0 + 37442a1 commit 447d2b3
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions textile/features.textile
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,7 @@ h3(#realtime-presence). RealtimePresence
** @(RTP2a)@ All incoming presence messages must be compared for newness with the matching member already in the @PresenceMap@, if one exists, where "matching" means they share the same @memberKey@ (or equivalently, they share both @connectionId@ and @clientId@)
** @(RTP2b)@ To compare for newness:
*** @(RTP2b1)@ If either presence message has a @connectionId@ which is not an initial substring of its @id@, compare them by @timestamp@ numerically. (This will be the case when one of them is a 'synthesized leave' event sent by realtime to indicate a connection disconnected unexpectedly 15s ago. Such messages will have an @id@ that does not correspond to its @connectionId@, as it wasn't actually published by that connection)
**** @(RTP2b1a)@ If the timestamps compare equal, the newly-incoming message is considered newer than the existing one
*** @(RTP2b2)@ Else split the @id@ of both presence messages (which will be of the form @connid:msgSerial:index@, e.g. @aaaaaa:0:0@) on the separator @:@, and parse the latter two as integers. Compare them first by @msgSerial@ numerically, then (if @msgSerial@ is equal) by @index@ numerically, larger being newer in both cases
** @(RTP2c)@ As there are no guarantees that during a @SYNC@ operation presence events will arrive in order, all presence messages from a @SYNC@ must also be compared for newness in the same way as they would from a @PRESENCE@
** @(RTP2d)@ When a presence message with an action of @ENTER@, @UPDATE@, or @PRESENT@ arrives, it should be added to the presence map with the action set to @PRESENT@
Expand Down

0 comments on commit 447d2b3

Please sign in to comment.