Class SyncBuilder
SyncClient; the builder itself should be created via Sync.client(BoxStore).-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds and returns a Sync client ready toSyncClient.start().changeListener(SyncChangeListener changeListener) Sets a listener to observe fine granular changes happening during sync.completedListener(SyncCompletedListener completedListener) Sets a listener to only observe Sync completed events.connectionListener(SyncConnectionListener connectionListener) Sets a listener to only observe Sync connection events.credentials(SyncCredentials credentials) AddsSyncCredentialsto authenticate the client with the server.credentials(List<SyncCredentials> credentials) Likecredentials(SyncCredentials), but accepts a list of credentials.filterVariable(String name, String value) Adds or replaces a Sync filter variable value for the given name.flags(int flags) Sets bit flags to adjust Sync behavior, like additional logging.listener(SyncListener listener) Sets a listener to observe all Sync events like login or sync completion.loginListener(SyncLoginListener loginListener) Sets a listener to only observe Sync login events.requestUpdatesMode(SyncBuilder.RequestUpdatesMode requestUpdatesMode) Configure automatic sync updates from the server.timeListener(SyncTimeListener timeListener) Sets a listener to only observe Sync time events.trustedCertificates(String[] paths) Configures a custom set of directory or file paths to search for trusted certificates in.Turns on sending of uncommitted acks.Adds a Sync server URL the client should connect to.Likeurl(String), but accepts a list of URLs.
-
Method Details
-
url
Adds a Sync server URL the client should connect to.This is typically a WebSockets URL starting with
ws://orwss://(for encrypted connections), for example if the server is running on localhostws://127.0.0.1:9999.Can be called multiple times to add multiple URLs for high availability and load balancing (like when using an ObjectBox Sync Server Cluster). A random URL is selected for each connection attempt.
- Parameters:
url- The URL of the Sync server on which the Sync protocol is exposed.- Returns:
- this builder for chaining
- See Also:
-
urls
Likeurl(String), but accepts a list of URLs.- Parameters:
urls- A list of URLs of Sync servers on which the Sync protocol is exposed.- Returns:
- this builder for chaining
- See Also:
-
credentials
AddsSyncCredentialsto authenticate the client with the server.The accepted credentials types depend on your Sync server configuration.
- Parameters:
credentials- credentials created using aSyncCredentialsfactory method, for exampleSyncCredentials.jwtIdToken(idToken).- See Also:
-
credentials
Likecredentials(SyncCredentials), but accepts a list of credentials.- Parameters:
credentials- a list of credentials where each element is created using aSyncCredentialsfactory method, for exampleSyncCredentials.jwtIdToken(idToken).- Returns:
- this builder for chaining
-
filterVariable
Adds or replaces a Sync filter variable value for the given name.Sync client filter variables can be used in server-side Sync filters to filter out objects that do not match the filter.
- See Also:
-
trustedCertificates
Configures a custom set of directory or file paths to search for trusted certificates in. The first path that exists will be used.Using this option is not recommended in most cases, as by default the sync client uses the certificate authorities trusted by the host platform.
-
flags
Sets bit flags to adjust Sync behavior, like additional logging.- Parameters:
flags- One or multipleSyncFlags, combined with bitwise or.
-
requestUpdatesMode
Configure automatic sync updates from the server. If automatic sync updates are turned off, they will need to be requested using the sync client.- See Also:
-
uncommittedAcks
Turns on sending of uncommitted acks. -
loginListener
Sets a listener to only observe Sync login events.This listener can also be
set or removedon the Sync client directly. -
completedListener
Sets a listener to only observe Sync completed events.This listener can also be
set or removedon the Sync client directly. -
changeListener
Sets a listener to observe fine granular changes happening during sync.This listener can also be
set or removedon the Sync client directly. -
timeListener
Sets a listener to only observe Sync time events.This listener can also be
set or removedon the Sync client directly. -
connectionListener
Sets a listener to only observe Sync connection events.This listener can also be
set or removedon the Sync client directly. -
listener
Sets a listener to observe all Sync events like login or sync completion.Note: this will replace any login, completed or connection listener.
This listener can also be
set or removedon the Sync client directly. -
build
Builds and returns a Sync client ready toSyncClient.start(). -
buildAndStart
-