Realm C++ SDK Version v2.2.0
|
Public Types | |
enum class | state { active , dying , inactive , waiting_for_access_token , paused } |
enum class | connection_state { disconnected , connecting , connected } |
Public Member Functions | |
enum state | state () const |
enum connection_state | connection_state () const |
void | wait_for_upload_completion (std::function< void(status)> &&callback) |
void | wait_for_download_completion (std::function< void(status)> &&callback) |
std::future< void > | wait_for_upload_completion () |
std::future< void > | wait_for_download_completion () |
void | pause () |
void | resume () |
void | reconnect () |
uint64_t | observe_connection_change (std::function< void(enum connection_state old_state, enum connection_state new_state)> &&callback) |
void | unregister_connection_change_observer (uint64_t token) |
operator std::weak_ptr< SyncSession > () | |
Friends | |
struct | internal::bridge::realm |
uint64_t realm::internal::bridge::sync_session::observe_connection_change | ( | std::function< void(enum connection_state old_state, enum connection_state new_state)> && | callback | ) |
Registers a callback that is invoked when the underlying sync session changes its connection state
void realm::internal::bridge::sync_session::pause | ( | ) |
Temporarily suspend syncronization and disconnect from the server.
The session will not attempt to connect to Atlas App Services until resume
is called or the Realm file is closed and re-opened.
void realm::internal::bridge::sync_session::reconnect | ( | ) |
Request an immediate reconnection to the server if the session is disconnected.
Realm automatically reconnects after disconnects with an exponential backoff, which is reset when the reachability handler reports a network status change. In some scenarios an application may wish to skip the reconnect delay, such as when an application receives a wake from background notification, which can be done by calling this method. Calling this method is never required.
This method is asynchronous and merely skips the current reconnect delay, so the connection state will still normally be disconnected immediately after calling it.
Has no effect if the session is currently connected.
void realm::internal::bridge::sync_session::resume | ( | ) |
Resume syncronization and reconnect to Atlas App Services after suspending.
This is a no-op if the session was already active or if the session is invalid. Newly created sessions begin in the Active state and do not need to be resumed.
void realm::internal::bridge::sync_session::unregister_connection_change_observer | ( | uint64_t | token | ) |
Unregister a previously registered notifier. If the token is invalid, this method does nothing.