Private #activePrivate #apiPrivate #concurrencyPrivate #cursorsPrivate #entityPrivate #gapPrivate #gapPrivate #gapPrivate #lastWhen the last gap triggered difference of an entity was started
Private #limitPrivate #livePrivate #loggerPrivate #maxPrivate #notifierPrivate #runPrivate #sourcePrivate #storePrivate #syncingPrivate #advanceCursors only move forward, and only to a newCursor of a difference response
Private #cachedIntervals of the local cache of an entity, taken from MessagesSyncStore.getCachedRanges when the store implements it and from MessagesSyncStore.getCachedWindow otherwise. Null when the store reports no coverage: the client is then treated as holding the whole history.
Private #cancelPrivate #cancelledPrivate #checkedEvery rejection here widens the declared coverage rather than narrows it, because a coverage narrower than the real one loses changes and nothing in the protocol reports that.
Private #enterPrivate #leavePrivate #loadPrivate #lookupCurrent server cursor of a single entity, used when a resync happens outside of a regular run
Private #onPrivate #onPrivate #onPrivate #resyncClient fell behind the journal retention: the difference cannot fill the gap, the entity is reloaded and its cursor is taken from the summary.
Only the ranges the client caches are reloaded, one request per interval, the rest of the history is read in its current state whenever the client loads it. Without a coverage the whole entity is reloaded, as before.
Optional currentCursor: numberOptional cachedRanges: CachedWindow[]Private #runPulls entities with a limited concurrency so that the background difference does not take over the connection the live stream is delivered through.
Private #scheduleA seq beyond the next one does not mean the records in between are lost: they may still be on their way, or they may be private messages of other users, which consume numbers this client never receives.
The cursor stays where it is and the entity is checked with a difference request, debounced to let the out of order records arrive and throttled to keep an entity with a lively private correspondence from requesting a difference on every message.
Private #selectPrivate #syncPrivate #syncOptional currentCursor: numberOptional run: SyncRunMove the cursor of an entity by a live event. Wired automatically by attach, exposed for clients that dispatch live events themselves.
Applying the change itself is none of this layer's business: the client does that in its regular handler of SfuEvent.MESSAGE and friends, whatever happens to the cursor here.
The cursor only follows the live stream when the sequence is unbroken. An event of an untracked entity, an event received while a difference of the same entity is in flight, and an already covered seq are ignored; a seq further than the next one is a gap and is checked with a difference request instead.
A watermark (MessageCursorEvent.watermark) is the exception: the server states there that everything meant for this client up to that seq has been sent, so the cursor takes it in one step. That is what keeps the records addressed to somebody else — delivery statuses of other members' messages, their private messages — from turning every live change into a difference request.
Run the synchronization on every connect and reconnect of the passed source, and move cursors along with the live stream of that source.
The first run happens on the nearest SfuEvent.CONNECTED, so attach before connecting.
Cursor of an entity as it is known to the current session
Whether the entity is tracked at all.
getCursor returns 0 both for an entity standing at the beginning of the journal and for an entity that was never synchronized. The difference matters: a cursor of an untracked entity claims a history the client does not have, so nothing but a difference response may create one.
Optional arg0: anyOptional arg0: anyEntity to synchronize first, normally the chat the user is looking at
Stop the run in progress. The already applied pages and their cursors stay, the rest of the entities is left for the next run.
The run is released right away, so a run started after it, for instance by a reconnect, is not held back by a request the dropped connection will never answer.
Ask the server for the cursor summary and pull the difference of every diverging entity.
Calling it while a run is in progress returns the promise of that run instead of starting a second one.
Pull the difference of a single entity, out of the regular run. Used to check an entity on demand, for instance when a gap in the live stream is suspected.
Optional currentCursor: numberserver cursor of the entity, only needed to store it after a full resync. When omitted, a resync reads it from a cursor summary.
Pending gap checks, at most one per entity