@Internal public class SyncClientImpl extends java.lang.Object implements SyncClient
SyncClient to access functionality,
this class may change without notice.| 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.
|
protected void |
finalize()
Users of this class should explicitly call
close() instead to avoid expensive finalization. |
long |
getLastLoginCode()
Response code of last login attempt.
|
java.lang.String |
getServerUrl()
Gets the sync server URL this client is connected to.
|
SyncState |
getSyncState()
Gets the current state of this sync client.
|
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()
Temporary only, try not to use it.
|
boolean |
requestFullSyncAndUpdates()
Temporary only, try not to use it.
|
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 changesListener)
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.
|
public java.lang.String getServerUrl()
SyncClientgetServerUrl in interface SyncClientpublic long getLastLoginCode()
SyncClientSyncLoginCodes.getLastLoginCode in interface SyncClientpublic boolean isLoggedIn()
SyncClientisLoggedIn in interface SyncClientpublic SyncState getSyncState()
close() was called.public void setSyncLoginListener(@Nullable
SyncLoginListener listener)
SyncClientnull to remove the listener.setSyncLoginListener in interface SyncClientpublic void setSyncCompletedListener(@Nullable
SyncCompletedListener listener)
SyncClientnull to remove the listener.setSyncCompletedListener in interface SyncClientpublic void setSyncChangeListener(@Nullable
SyncChangeListener changesListener)
SyncClientSyncChangeListener. Replaces a previously set listener.
Set to null to remove the listener.setSyncChangeListener in interface SyncClientpublic void setSyncConnectionListener(@Nullable
SyncConnectionListener listener)
SyncClientnull to remove the listener.setSyncConnectionListener in interface SyncClientpublic void setSyncListener(@Nullable
SyncListener listener)
SyncClientSyncChangeListener.
Set to null to remove the listener.setSyncListener in interface SyncClientpublic void setLoginCredentials(SyncCredentials credentials)
SyncClientsetLoginCredentials in interface SyncClientpublic boolean awaitFirstLogin(long millisToWait)
SyncClientSyncClient.isLoggedIn() or SyncClient.getLastLoginCode() afterwards to determine if login was successful.
Starts the sync if it is not already.awaitFirstLogin in interface SyncClientpublic void start()
SyncClientstart in interface SyncClientpublic boolean isStarted()
SyncClientisStarted in interface SyncClientpublic void stop()
SyncClientstop in interface SyncClientpublic void close()
SyncClientclose in interface SyncClientclose in interface java.io.Closeableclose in interface java.lang.AutoCloseableprotected void finalize()
throws java.lang.Throwable
close() instead to avoid expensive finalization.finalize in class java.lang.Objectjava.lang.Throwable@Experimental public boolean requestFullSync()
requestFullSync in interface SyncClient@Experimental public boolean requestFullSyncAndUpdates()
public boolean requestUpdates()
SyncClientrequestUpdatesMode(MANUAL).requestUpdates in interface SyncClientSyncClient.cancelUpdates()public boolean requestUpdatesOnce()
SyncClientrequestUpdatesMode(MANUAL).requestUpdatesOnce in interface SyncClientpublic boolean cancelUpdates()
SyncClientcancelUpdates in interface SyncClientSyncClient.requestUpdates()public void notifyConnectionAvailable()
SyncClientThis can help speed up reconnecting to the sync server.
notifyConnectionAvailable in interface SyncClient