SyncClient class

A Sync client is used to connect to an ObjectBox Sync server.

Constructors

SyncClient(Store _store, List<String> serverUrls, List<SyncCredentials> credentials, {Map<String, String>? filterVariables, List<String>? certificatePaths, int? flags})
Creates a Sync client associated with the given store and options. This does not initiate any connection attempts yet, call start to do so.

Properties

changeEvents → Stream<List<SyncChange>>
A broadcast stream of incoming synced data changes.
no setter
completionEvents → Stream<void>
A broadcast stream of sync completion events.
no setter
connectionEvents → Stream<SyncConnectionEvent>
A broadcast stream of connection state changes (connect/disconnect).
no setter
hashCode → int
The hash code for this object.
no setterinherited
loginEvents → Stream<SyncLoginEvent>
A broadcast stream of login events (success/failure).
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

applyFilterVariables() → void
Applies all pending Sync filter variable updates (from putFilterVariable and removeFilterVariable calls).
cancelUpdates() → bool
Cancels updates from the server so that it will stop sending updates.
close() → void
Closes and cleans up all resources used by this sync client. It can no longer be used afterwards, make a new sync client instead. Does nothing if this sync client has already been closed.
isClosed() → bool
Returns if this sync client is closed and can no longer be used.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
outgoingMessageCount({int limit = 0}) → int
Count the number of messages in the outgoing queue, i.e. those waiting to be sent to the server.
protocolVersionServer() → int
Returns the protocol version of the server after a connection is established (or attempted), zero otherwise.
putFilterVariable(String name, String value) → void
Adds or replaces a Sync filter variable value for the given name.
removeAllFilterVariables() → void
Removes all previously added Sync filter variable values.
removeFilterVariable(String name) → void
Removes a previously added Sync filter variable value.
requestUpdates({required bool subscribeForFuturePushes}) → bool
Requests updates from the server since we last synchronized.
setCredentials(SyncCredentials creds) → void
Sets credentials to authenticate the client with the server.
setMultipleCredentials(List<SyncCredentials> credentials) → void
Like setCredentials, but accepts a list of credentials.
setRequestUpdatesMode(SyncRequestUpdatesMode mode) → void
Configures how sync updates are received from the server.
start() → void
Once the sync client is configured, you can start it to initiate synchronization.
state() → SyncState
Gets the current sync client state.
stop() → void
Stops this sync client and closes the connection to the server.
toString() → String
A string representation of this object.
inherited
triggerReconnect() → bool
Triggers a reconnection attempt immediately. Returns if a reconnect was actually triggered.

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

protocolVersion() → int
Returns the protocol version this client uses.