io.realm.mongodb.sync
A session controls how data is synchronized between a single Realm on the device and the server Realm on the Realm Object Server.A Session is created by opening a Realm instance using a SyncConfiguration . Once a session has been created, it will continue to exist until the app is closed or all threads using this SyncConfiguration closes their respective Realm s.
Una sesión está controlada por Realm, pero puede proporcionar información adicional en casos de errores. Estos errores se transmiten en el SyncSession.ErrorHandler .
Al crear una sesión, Realm establecerá una conexión con el servidor. Esta conexión está controlada por Realm y puede compartirse entre varias sesiones. Es posible obtener información sobre la conexión mediante addConnectionChangeListener(ConnectionListener) e isConnected().
La sesión en sí tiene un ciclo de vida diferente al de la conexión subyacente. El estado de la sesión se puede consultar mediante getState().
El objeto SyncSession es seguro para subprocesos (thread safe).
Nested Class Summary
Modificador y Tipo | Clase y descripción |
|---|---|
| |
| |
|
Resumen del método
Modificador y Tipo | Método y descripción |
|---|---|
public synchronized void | Adds a listener tracking changes to the connection backing this session. |
public synchronized void | Agrega un listener de progreso que rastrea los cambios que deben descargarse desde el servidor de objeto Realm. |
public synchronized void | Adds a progress listener tracking changes that need to be uploaded from the device to the Realm Object Server. |
public booleano | Calling this method will block until all known remote changes have been downloaded and applied to the Realm or the specified timeout is hit. |
public void | Llamar a este método bloqueará hasta que se hayan descargado y aplicado todos los cambios remotos conocidos al Realm. |
público SyncConfiguration | Returns the SyncConfiguration that is responsible for controlling the session. |
public ConnectionState | Get the current state of the connection used by the session as defined in ConnectionState . |
public URI | getServerUrl () Returns the URI describing the remote Realm which this session connects to and synchronizes changes with. |
public SyncSession.estado | getState () Obtenga el estado de la sesión actual, como se define en SyncSession.State. |
public User | getUser () Devuelve el usuario definido por SyncConfiguration que se utiliza para conectarse a MongoDB Realm. |
public booleano | isConnected () Checks if the session is connected to the server and can synchronize data. |
public synchronized void | Remueve una ConnectionListener previamente registrada. |
public synchronized void | Remueve un listener de progreso. |
public synchronized void | start () Intenta iniciar la sesión y habilitar la sincronización con el servidor de objetos Realm. |
public synchronized void | stop () Stops any synchronization with the Realm Object Server until the Realm is re-opened again after fully closing it. |
public booleano | Calling this method will block until all known local changes have been uploaded to the server or the specified timeout is hit. |
public void | Calling this method will block until all known local changes have been uploaded to the server. |
Inherited Methods
Methods inherited from class java.lang.Object :
getClass,hashCode,equals,clone,toString,notify,notifyAll,wait,wait,wait,finalize
Detalle del método
addConnectionChangeListener
Añade un detector que rastrea los cambios en la conexión que respalda esta sesión. Consulta ConnectionState para más detalles. Parámetros
Throws
|
addDownloadProgressListener
Adds a progress listener tracking changes that need to be downloaded from the Realm Object Server.The ProgressListener will be triggered immediately when registered, and periodically afterwards. Parámetros
|
addUploadProgressListener
Adds a progress listener tracking changes that need to be uploaded from the device to the Realm Object Server.The ProgressListener will be triggered immediately when registered, and periodically afterwards. Parámetros
|
downloadAllServerChanges
Llamar a este método bloqueará hasta que todos los cambios remotos conocidos hayan sido descargados y aplicados al Realm o hasta que se alcance el tiempo límite especificado. Esto implicará acceso a la red, por lo que llamar a este método solo debe realizarse desde un hilo que no sea de la Interfaz de Usuario. Este método no se puede llamar antes de que el Realm esté abierto. Devuelve
Throws
|
public void downloadAllServerChanges () |
|---|
Calling this method will block until all known remote changes have been downloaded and applied to the Realm. This will involve network access, so calling this method should only be done from a non-UI thread.If the device is offline, this method might never return. This method cannot be called before the session has been started. Throws
|
getConfiguration
public SyncConfiguration getConfiguration () |
|---|
Returns the SyncConfiguration that is responsible for controlling the session. Devuelve SyncConfiguration that defines and controls this session. |
getConnectionState
public ConnectionState getConnectionState () |
|---|
Get the current state of the connection used by the session as defined in ConnectionState . Devuelve el estado de conexión utilizado por la sesión. |
getServerUrl
public URI getServerUrl () |
|---|
getState
public SyncSession.State getState () |
|---|
Obtenga el estado de la sesión actual, como se define en SyncSession.State. Note that the state may change after this method returns. Devuelve the state of the session. |
getUser
Devuelve el usuario definido por SyncConfiguration que se utiliza para conectarse a MongoDB Realm. Devuelve Usuario utilizado para autenticar la sesión en MongoDB Realm. |
isConnected
public boolean isConnected () |
|---|
Checks if the session is connected to the server and can synchronize data. This is a best guess effort. To conserve battery the underlying implementation uses heartbeats to detect if the connection is still available. So if no data is actively being synced and some time has elapsed since the last heartbeat, the connection could have been dropped but this method will still return Devuelve
|
removeConnectionChangeListener
Remueve una ConnectionListener previamente registrada. Parámetros
Throws
|
removeProgressListener
Removes a progress listener. If the listener wasn't registered, this method will do nothing. Parámetros
|
Inicio
public synchronized void start () |
|---|
Attempts to start the session and enable synchronization with the Realm Object Server.This happens automatically when opening the Realm instance, so doing it manually should only be needed if the session was stopped using stop() . If the session was already started, calling this method will do nothing. A session is considered started if getState() returns State.ACTIVE . If the session is State.DYING , the session will be moved back to State.ACTIVE . |
parada
uploadAllLocalChanges
Calling this method will block until all known local changes have been uploaded to the server or the specified timeout is hit. This will involve network access, so calling this method should only be done from a non-UI thread.This method cannot be called before the Realm has been opened. Devuelve
Throws
|
public void uploadAllLocalChanges () |
|---|
Llamar a este método bloqueará hasta que todos los cambios locales conocidos se hayan subido al servidor. Esto implicará acceso a la red, por lo que solo se debe llamar a este método desde un subproceso que no sea de Interfaz de Usuario. Si el dispositivo está sin conexión, este método podría no devolver nunca una respuesta. This method cannot be called before the Realm has been opened. Throws
|