Class: SyncApi

SyncApi

new SyncApi(client, opts)

Internal class - unstable. Construct an entity which is able to sync with a homeserver.
Parameters:
Name Type Description
client MatrixClient The matrix client instance to use.
opts Object Config options
Source:

Methods

_getGuestFilter() → {string}

Source:
Returns:
Type
string

_mapSyncEventsFormat(obj, room) → {Array.<MatrixEvent>}

Parameters:
Name Type Description
obj Object
room Room
Source:
Returns:
Type
Array.<MatrixEvent>

_mapSyncResponseToRoomArray(obj) → {Array.<Object>}

Parameters:
Name Type Description
obj Object
Source:
Returns:
Type
Array.<Object>

_onOnline()

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.
Source:

_peekPoll(roomId, token)

Do a peek room poll.
Parameters:
Name Type Description
roomId string
token string from= token
Source:

_pokeKeepAlive()

Source:

_processRoomEvents(room, stateEventList, timelineEventListnullable)

Parameters:
Name Type Attributes Description
room Room
stateEventList Array.<MatrixEvent> A list of state events. This is the state at the *START* of the timeline list if it is supplied.
timelineEventList Array.<MatrixEvent> <nullable>
A list of timeline events. Lower index is earlier in time. Higher index is later.
Source:

_processSyncResponse(syncToken, data)

Process data returned from a sync response and propagate it into the model objects
Parameters:
Name Type Description
syncToken string the old next_batch token sent to this sync request.
data Object The response from /sync
Source:

_resolveInvites(room)

Parameters:
Name Type Description
room Room
Source:

_startKeepAlives(delay) → {promise}

Starts polling the connectivity check endpoint
Parameters:
Name Type Description
delay number How long to delay until the first poll. defaults to a short, randomised interval (to prevent tightlooping if /versions succeeds but /sync etc. fail).
Source:
Returns:
Type
promise

_sync(syncOptions)

Invoke me to do /sync calls
Parameters:
Name Type Description
syncOptions Object
Properties
Name Type Description
filterId string
hasSyncedBefore boolean
Source:

_updateSyncState(newState, data)

Sets the sync state and emits an event to say so
Parameters:
Name Type Description
newState String The new state string
data Object Object of additional data to emit in the event
Source:

createRoom(roomId) → {Room}

Parameters:
Name Type Description
roomId string
Source:
Returns:
Type
Room

getSyncState() → (nullable) {String}

Returns the current state of this sync object
Source:
See:
  • module:client~MatrixClient#event:"sync"
Returns:
Type
String

peek(roomId) → {Promise}

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.
Parameters:
Name Type Description
roomId string The room ID to peek into.
Source:
Returns:
A promise which resolves once the room has been added to the store.
Type
Promise

retryImmediately() → {boolean}

Retry a backed off syncing request immediately. This should only be used when the user explicitly attempts to retry their lost connection.
Source:
Returns:
True if this resulted in a request being retried.
Type
boolean

stop()

Stops the sync object from syncing.
Source:

stopPeeking()

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

sync()

Main entry point
Source:

syncLeftRooms() → {Promise}

Sync rooms the user has left.
Source:
Returns:
Resolved when they've been added to the store.
Type
Promise