Constructors

Properties

#activeEntityKey: string = null
#concurrency: number
#cursors: Map<string, number> = ...
#entityFilter: ((cursor, localCursor) => boolean)

Type declaration

    • (cursor, localCursor): boolean
    • Parameters

      Returns boolean

#gapCheckDelayMs: number
#gapCheckMinIntervalMs: number
#gapTimers: Map<string, Timeout> = ...

Pending gap checks, at most one per entity

#lastGapCheck: Map<string, number> = ...

When the last gap triggered difference of an entity was started

#limit: number
#liveCursor: boolean
#logger: default = ...
#maxPagesPerEntity: number
#notifier: Notifier<MessagesSyncEvent, object> = ...
#run: SyncRun = null
#source: MessagesSyncEventSource = null
#syncing: Map<string, number> = ...

Methods

  • Cursors only move forward, and only to a newCursor of a difference response

    Parameters

    Returns Promise<void>

  • Returns void

  • Every 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.

    Parameters

    Returns CachedWindow[]

  • Parameters

    • key: string

    Returns void

  • Parameters

    • key: string

    Returns void

  • Returns Promise<void>

  • Current server cursor of a single entity, used when a resync happens outside of a regular run

    Parameters

    Returns Promise<number>

  • Returns void

  • Returns void

  • Parameters

    Returns void

  • Client 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.

    Parameters

    Returns Promise<number>

  • Pulls entities with a limited concurrency so that the background difference does not take over the connection the live stream is delivered through.

    Parameters

    Returns Promise<EntitySyncResult[]>

  • A 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.

    Parameters

    • entity: SyncEntity
    • key: string
    • localCursor: number
    • eventCursor: number

    Returns void

  • Parameters

    • run: SyncRun

    Returns Promise<SyncResult>

  • Parameters

    • entity: SyncEntity
    • Optional currentCursor: number
    • Optional run: SyncRun

    Returns Promise<EntitySyncResult>

  • Move 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.

    Parameters

    Returns void

  • Cursors of the current session

    Returns Map<string, number>

  • Cursor of an entity as it is known to the current session

    Parameters

    Returns number

  • 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.

    Parameters

    Returns boolean

  • 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.

    Returns MessagesSynchronizer

  • 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.

    Returns Promise<SyncResult>

  • 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.

    Parameters

    • entity: SyncEntity
    • Optional currentCursor: number

      server cursor of the entity, only needed to store it after a full resync. When omitted, a resync reads it from a cursor summary.

    Returns Promise<EntitySyncResult>