@Experimental
public interface SyncClient
extends java.io.Closeable
Sync.client(io.objectbox.BoxStore, java.lang.String, io.objectbox.sync.SyncCredentials).
Keep the instance around (avoid garbage collection) while you want to have sync ongoing.
For a clean shutdown, call close().
SyncClient is thread-safe.
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitFirstLogin(long millisToWait)
Waits until the sync client receives a response to its first (connection and) login attempt
or until the given time has expired.
|
boolean |
cancelUpdates()
Asks the server to pause sync updates.
|
void |
close()
Closes and cleans up all resources used by this sync client.
|
long |
getLastLoginCode()
Response code of last login attempt.
|
java.lang.String |
getServerUrl()
Gets the sync server URL this client is connected to.
|
boolean |
isLoggedIn()
Flag indicating if the sync client was started.
|
boolean |
isStarted()
Flag indicating if the sync client was started.
|
void |
notifyConnectionAvailable()
Lets the sync client know that a working network connection
is available.
|
boolean |
requestFullSync()
Experimental.
|
boolean |
requestUpdates()
Asks the sync server to resume sync updates.
|
boolean |
requestUpdatesOnce()
Asks the server to send sync updates until this sync client is up-to-date, then pauses sync updates again.
|
void |
setLoginCredentials(SyncCredentials credentials)
Updates the login credentials.
|
void |
setSyncChangeListener(SyncChangeListener listener)
Sets a
SyncChangeListener. |
void |
setSyncCompletedListener(SyncCompletedListener listener)
Sets a listener to observe Sync completed events.
|
void |
setSyncConnectionListener(SyncConnectionListener listener)
Sets a listener to observe Sync connection events.
|
void |
setSyncListener(SyncListener listener)
Sets a listener to observe all Sync events.
|
void |
setSyncLoginListener(SyncLoginListener listener)
Sets a listener to observe login events.
|
void |
start()
Starts the client.
|
void |
stop()
Stops the client.
|
java.lang.String getServerUrl()
boolean isStarted()
boolean isLoggedIn()
long getLastLoginCode()
SyncLoginCodes.void setSyncLoginListener(@Nullable
SyncLoginListener listener)
null to remove the listener.void setSyncCompletedListener(@Nullable
SyncCompletedListener listener)
null to remove the listener.void setSyncConnectionListener(@Nullable
SyncConnectionListener listener)
null to remove the listener.void setSyncListener(@Nullable
SyncListener listener)
SyncChangeListener.
Set to null to remove the listener.void setSyncChangeListener(@Nullable
SyncChangeListener listener)
SyncChangeListener. Replaces a previously set listener.
Set to null to remove the listener.void setLoginCredentials(SyncCredentials credentials)
boolean awaitFirstLogin(long millisToWait)
isLoggedIn() or getLastLoginCode() afterwards to determine if login was successful.
Starts the sync if it is not already.void start()
void stop()
void close()
close in interface java.lang.AutoCloseableclose in interface java.io.Closeableboolean requestUpdates()
requestUpdatesMode(MANUAL).cancelUpdates()boolean requestUpdatesOnce()
requestUpdatesMode(MANUAL).boolean cancelUpdates()
requestUpdates()@Experimental boolean requestFullSync()
Temporary only, try not to use it.
Request a sync of all previous changes from the server.
void notifyConnectionAvailable()
This can help speed up reconnecting to the sync server.