|
Ditto 5.0.0
|
Provides access to sync related functionality of Ditto. More...
Public Member Functions | |
| Sync (const Sync &other)=default | |
| Sync (Sync &&other)=default | |
| Sync & | operator= (const Sync &other)=default |
| Sync & | operator= (Sync &&other)=default |
| void | start () const |
| Starts the network transports. Ditto will connect to other devices and sync with them where appropriate. | |
| void | stop () const |
| Stops all network transports. | |
| bool | is_active () const |
| Returns a flag indicating whether or not sync is active. Use start to activate sync and stop to deactivate sync. | |
| std::shared_ptr< SyncSubscription > | register_subscription (std::string query, nlohmann::json query_arguments=nullptr) |
Installs and returns a sync subscription for a query, configuring Ditto to receive updates from other peers for documents matching that query. The provided query must be a SELECT query. | |
| SyncSubscriptionSet | get_subscriptions () const |
| Returns a snapshot of all active subscriptions. | |
Provides access to sync related functionality of Ditto.
| bool ditto::Sync::is_active | ( | ) | const |
| std::shared_ptr< SyncSubscription > ditto::Sync::register_subscription | ( | std::string | query, |
| nlohmann::json | query_arguments = nullptr |
||
| ) |
Installs and returns a sync subscription for a query, configuring Ditto to receive updates from other peers for documents matching that query. The provided query must be a SELECT query.
| query | a string containing a valid query expressed in DQL. |
| query_arguments | a dictionary of values keyed by the placeholder name without the leading :. Example: {{"mileage", 123}}. |
SyncSubscription for the provided query and arguments. You'll have to keep it to be able to cancel the replication subscription, i.e. remove it from the store again. Otherwise it will remain active until the Ditto instance goes out of scope. | void ditto::Sync::start | ( | ) | const |
Starts the network transports. Ditto will connect to other devices and sync with them where appropriate.
By default Ditto will enable all peer-to-peer transport types. The default network configuration can be modified with update_transport_config or replaced with set_transport_config.
| DittoError | thrown if the Ditto instance hasn't been activated by a successful call to set_offline_only_license_token. If running on Android, throws if a Context has not been provided via the Ditto constructor's android_context parameter. |
| void ditto::Sync::stop | ( | ) | const |
Stops all network transports.
You may continue to use the Ditto store locally but no data will sync to or from other devices.