Internal class - unstable. Construct an entity which is able to sync with a homeserver.

Param

The matrix client instance to use.

Param

Config options

Param

Crypto manager

Param

A function which is called with a room ID and returns a boolean. It should return 'true' if the SDK can SAFELY remove events from this room. It may not be safe to remove events if there are other references to the timelines for this room. Default: returns false.

Param

True to perform syncing without automatically updating presence.

Hierarchy

  • SyncApi

Constructors

Properties

_peekRoom: Optional<Room> = null
abortController?: AbortController
catchingUp: boolean = false
client: MatrixClient
connectionReturnedDefer?: IDeferred<boolean>
currentSyncRequest?: Promise<ISyncResponse>
failedSyncCount: number = 0
keepAliveTimer?: Timeout
notifEvents: MatrixEvent[] = []
opts: Partial<IStoredClientOpts> = {}
running: boolean = false
savedSyncPromise?: Promise<void>
storeIsInvalid: boolean = false
syncState: null | SyncState = null
syncStateData?: ISyncStateData

Methods

  • Returns Promise<void>

  • Returns Promise<{
        filter?: Filter;
        filterId?: string;
    }>

  • Returns the current state of this sync object

    See

    module:client~MatrixClient#event:"sync"

    Returns

    Returns null | SyncState

  • Returns the additional data object associated with the current sync state, or null if there is no such data. Sync errors, if available, are put in the 'error' key of this object.

    Returns

    Returns null | ISyncStateData

  • Injects events into a room's model.

    Parameters

    • room: Room
    • stateEventList: MatrixEvent[]

      A list of state events. This is the state at the START of the timeline list if it is supplied.

    • Optional timelineEventList: MatrixEvent[]

      A list of timeline events, including threaded. Lower index is earlier in time. Higher index is later.

    • fromCache: boolean = false

      whether the sync response came from cache

    Returns Promise<void>

  • When we see the marker state change in the room, we know there is some new historical messages imported by MSC2716 /batch_send somewhere in the room and we need to throw away the timeline to make sure the historical messages are shown when we paginate /messages again.

    Parameters

    • room: Room

      The room where the marker event was sent

    • markerEvent: MatrixEvent

      The new marker event

    • setStateOptions: IMarkerFoundOptions = {}

      When timelineWasEmpty is set as true, the given marker event will be ignored

    Returns void

  • Event handler for the 'online' event This event is generally unreliable and precise behaviour varies between browsers, so we poll for connectivity too, but this might help us reconnect a little faster.

    Returns void

  • Peek into a room. This will result in the room in question being synced so it is accessible via getRooms(). Live updates for the room will be provided.

    Returns

    A promise which resolves once the room has been added to the store.

    Parameters

    • roomId: string

      The room ID to peek into.

    Returns Promise<Room>

  • Do a peek room poll.

    Parameters

    • peekRoom: Room
    • Optional token: string

      from= token

    Returns void

  • Make a dummy call to /_matrix/client/versions, to see if the HS is reachable.

    On failure, schedules a call back to itself. On success, resolves this.connectionReturnedDefer.

    Parameters

    • connDidFail: boolean = false

      True if a connectivity failure has been detected. Optional.

    Returns void

  • Takes a list of timelineEvents and adds and adds to notifEvents as appropriate. This must be called after the room the events belong to has been stored.

    Parameters

    • room: Room
    • Optional timelineEventList: MatrixEvent[]

      A list of timeline events. Lower index is earlier in time. Higher index is later.

    Returns void

  • Process data returned from a sync response and propagate it into the model objects

    Parameters

    Returns Promise<void>

  • Parameters

    • savedSyncPromise: undefined | Promise<void>
    • error: Error

    Returns Promise<void>

  • Retry a backed off syncing request immediately. This should only be used when the user explicitly attempts to retry their lost connection.

    Returns

    True if this resulted in a request being retried.

    Returns boolean

  • Starts polling the connectivity check endpoint

    Returns

    which resolves once the connection returns

    Parameters

    • Optional delay: number

      How long to delay until the first poll. defaults to a short, randomised interval (to prevent tight-looping if /versions succeeds but /sync etc. fail).

    Returns Promise<boolean>

  • Stops the sync object from syncing.

    Returns void

  • Stop polling for updates in the peeked room. NOPs if there is no room being peeked.

    Returns void

  • Main entry point

    Returns Promise<void>

  • Process a single set of cached sync data.

    Parameters

    • savedSync: ISavedSync

      a saved sync that was persisted by a store. This should have been acquired via client.store.getSavedSync().

    Returns Promise<void>

  • Sync rooms the user has left.

    Returns

    Resolved when they've been added to the store.

    Returns Promise<Room[]>

  • Is the lazy loading option different than in previous session?

    Returns

    whether or not the option has changed compared to the previous session

    Parameters

    • lazyLoadMembers: boolean = false

      current options for lazy loading

    Returns Promise<boolean>

Generated using TypeDoc