ObjectBox C and C++ API  4.0.3
ObjectBox Sync C API

Classes

struct  OBX_sync_change
 
struct  OBX_sync_change_array
 
struct  OBX_sync_object
 A single data object contained in a OBX_sync_msg_objects message. More...
 
struct  OBX_sync_msg_objects
 Incubating message that carries multiple data "objects" (e.g. FlatBuffers, strings, raw bytes). Interpretation is up to the application. Does not involve any persistence or delivery guarantees at the moment. More...
 
struct  OBX_custom_msg_server_functions
 Struct of the custom server function callbacks. In order to implement the custom server, you must provide custom methods for each of the members of this struct. This is then passed to obx_custom_msg_server_register() to register the custom server. More...
 
struct  OBX_custom_msg_client_functions
 Struct of the custom client function callbacks. In order to implement the custom client, you must provide custom methods for each of the members of this struct. This is then passed to obx_custom_msg_client_register() to register the custom client. More...
 

Typedefs

typedef struct OBX_sync OBX_sync
 
typedef struct OBX_sync_change OBX_sync_change
 
typedef struct OBX_sync_change_array OBX_sync_change_array
 
typedef struct OBX_sync_object OBX_sync_object
 A single data object contained in a OBX_sync_msg_objects message. More...
 
typedef struct OBX_sync_msg_objects OBX_sync_msg_objects
 Incubating message that carries multiple data "objects" (e.g. FlatBuffers, strings, raw bytes). Interpretation is up to the application. Does not involve any persistence or delivery guarantees at the moment. More...
 
typedef struct OBX_sync_msg_objects_builder OBX_sync_msg_objects_builder
 
typedef void OBX_sync_listener_connect(void *arg)
 Called when connection is established. More...
 
typedef void OBX_sync_listener_disconnect(void *arg)
 Called when connection is closed/lost. More...
 
typedef void OBX_sync_listener_login(void *arg)
 Called on successful login. More...
 
typedef void OBX_sync_listener_login_failure(void *arg, OBXSyncCode code)
 Called on a login failure. More...
 
typedef void OBX_sync_listener_complete(void *arg)
 Called when synchronization is complete. More...
 
typedef void OBX_sync_listener_error(void *arg, OBXSyncError error)
 Callend when sync-level errors occur. More...
 
typedef void OBX_sync_listener_change(void *arg, const OBX_sync_change_array *changes)
 Called with fine grained sync changes (IDs of put and removed entities) More...
 
typedef void OBX_sync_listener_server_time(void *arg, int64_t timestamp_ns)
 Called when a server time information is received on the client. More...
 
typedef void OBX_sync_listener_msg_objects(void *arg, const OBX_sync_msg_objects *msg_objects)
 
typedef struct OBX_sync_server OBX_sync_server
 
typedef void * OBX_custom_msg_server_func_create(uint64_t server_id, const char *url, const char *cert_path, void *config_user_data)
 Callback to create a custom messaging server. Must be provided to implement a custom server. See notes on OBX_custom_msg_server_functions for more details. More...
 
typedef obx_err OBX_custom_msg_server_func_start(void *server_user_data, uint64_t *out_port)
 Callback to start a custom server. Must be provided to implement a custom server. See notes on OBX_custom_msg_server_functions for more details. More...
 
typedef void OBX_custom_msg_server_func_stop(void *server_user_data)
 Callback to stop and close the custom server (e.g. further messages delivery will be rejected). Must be provided to implement a custom server. See notes on OBX_custom_msg_server_functions for more details. This includes the store associated with the server; it gets closed and must not be used anymore after this call. More...
 
typedef void OBX_custom_msg_server_func_shutdown(void *server_user_data)
 Callback to shut the custom server down, freeing its resources (the custom server is not used after this point). Must be provided to implement a custom server. See notes on OBX_custom_msg_server_functions for more details. More...
 
typedef bool OBX_custom_msg_server_func_client_connection_send_async(OBX_bytes_lazy *bytes, void *server_user_data, void *connection_user_data)
 Callback to enqueue a message for sending. Must be provided to implement a custom server. See notes on OBX_custom_msg_server_functions for more details. More...
 
typedef void OBX_custom_msg_server_func_client_connection_close(void *server_user_data, void *connection_user_data)
 Callback to close the sync client connection to the custom server. Must be provided to implement a custom server. See notes on OBX_custom_msg_server_functions for more details. More...
 
typedef void OBX_custom_msg_server_func_client_connection_shutdown(void *connection_user_data)
 Callback to shutdown and free all resources associated with the sync client connection to the custom server. Note that the custom server may already have been shutdown at this point (e.g. no server user data is supplied). Must be provided to implement a custom server. See notes on OBX_custom_msg_server_functions for more details. More...
 
typedef struct OBX_custom_msg_server_functions OBX_custom_msg_server_functions
 Struct of the custom server function callbacks. In order to implement the custom server, you must provide custom methods for each of the members of this struct. This is then passed to obx_custom_msg_server_register() to register the custom server. More...
 
typedef void * OBX_custom_msg_client_func_create(uint64_t client_id, const char *url, const char *cert_path, void *config_user_data)
 Callback to create a custom messaging client. Must be provided to implement a custom client. See notes on OBX_custom_msg_client_functions for more details. More...
 
typedef obx_err OBX_custom_msg_client_func_start(void *client_user_data)
 Callback to start the client. Must be provided to implement a custom client. See notes on OBX_custom_msg_client_functions for more details. More...
 
typedef void OBX_custom_msg_client_func_stop(void *client_user_data)
 Callback to stop and close the client (e.g. further messages delivery will be rejected). Must be provided to implement a custom client. See notes on OBX_custom_msg_client_functions for more details. More...
 
typedef void OBX_custom_msg_client_func_join(void *client_user_data)
 Must be provided to implement a custom client. See notes on OBX_custom_msg_client_functions for more details. More...
 
typedef bool OBX_custom_msg_client_func_connect(void *client_user_data)
 Callback that tells the client it shall start trying to connect. Must be provided to implement a custom client. See notes on OBX_custom_msg_client_functions for more details. More...
 
typedef void OBX_custom_msg_client_func_disconnect(bool clear_outgoing_messages, void *client_user_data)
 Callback that tells the client it shall disconnect. Must be provided to implement a custom client. See notes on OBX_custom_msg_client_functions for more details. More...
 
typedef void OBX_custom_msg_client_func_shutdown(void *client_user_data)
 Callback to shut the custom client down, freeing its resources. The custom client is not used after this point. Must be provided to implement a custom client. See notes on OBX_custom_msg_client_functions for more details. More...
 
typedef bool OBX_custom_msg_client_func_send_async(OBX_bytes_lazy *bytes, void *client_user_data)
 Callback to enqueue a message for sending. Must be provided to implement a custom client. See notes on OBX_custom_msg_client_functions for more details. More...
 
typedef void OBX_custom_msg_client_func_clear_outgoing_messages(void *client_user_data)
 Callback to clear all outgoing messages. Must be provided to implement a custom client. See notes on OBX_custom_msg_client_functions for more details. More...
 
typedef struct OBX_custom_msg_client_functions OBX_custom_msg_client_functions
 Struct of the custom client function callbacks. In order to implement the custom client, you must provide custom methods for each of the members of this struct. This is then passed to obx_custom_msg_client_register() to register the custom client. More...
 

Enumerations

enum  OBXSyncCredentialsType {
  OBXSyncCredentialsType_NONE = 1 , OBXSyncCredentialsType_SHARED_SECRET = 2 , OBXSyncCredentialsType_GOOGLE_AUTH = 3 , OBXSyncCredentialsType_SHARED_SECRET_SIPPED = 4 ,
  OBXSyncCredentialsType_OBX_ADMIN_USER = 5 , OBXSyncCredentialsType_USER_PASSWORD = 6
}
 Specifies user-side credential types as well as server-side authenticator types. Some credential types do not make sense as authenticators such as OBXSyncCredentialsType_USER_PASSWORD which specifies a generic client-side credential type. More...
 
enum  OBXRequestUpdatesMode { OBXRequestUpdatesMode_MANUAL = 0 , OBXRequestUpdatesMode_AUTO = 1 , OBXRequestUpdatesMode_AUTO_NO_PUSHES = 2 }
 
enum  OBXSyncState {
  OBXSyncState_CREATED = 1 , OBXSyncState_STARTED = 2 , OBXSyncState_CONNECTED = 3 , OBXSyncState_LOGGED_IN = 4 ,
  OBXSyncState_DISCONNECTED = 5 , OBXSyncState_STOPPED = 6 , OBXSyncState_DEAD = 7
}
 
enum  OBXSyncCode {
  OBXSyncCode_OK = 20 , OBXSyncCode_REQ_REJECTED = 40 , OBXSyncCode_CREDENTIALS_REJECTED = 43 , OBXSyncCode_UNKNOWN = 50 ,
  OBXSyncCode_AUTH_UNREACHABLE = 53 , OBXSyncCode_BAD_VERSION = 55 , OBXSyncCode_CLIENT_ID_TAKEN = 61 , OBXSyncCode_TX_VIOLATED_UNIQUE = 71
}
 
enum  OBXSyncError { OBXSyncError_REJECT_TX_NO_PERMISSION = 1 }
 Sync-level error reporting codes, passed via obx_sync_listener_error(). More...
 
enum  OBXSyncObjectType { OBXSyncObjectType_FlatBuffers = 1 , OBXSyncObjectType_String = 2 , OBXSyncObjectType_Raw = 3 }
 
enum  OBXSyncStats {
  OBXSyncStats_connects = 1 , OBXSyncStats_logins = 2 , OBXSyncStats_messagesReceived = 3 , OBXSyncStats_messagesSent = 4 ,
  OBXSyncStats_messageSendFailures = 5 , OBXSyncStats_messageBytesReceived = 6 , OBXSyncStats_messageBytesSent = 7
}
 Stats counter type IDs as passed to obx_sync_stats_u64(). More...
 
enum  OBXSyncServerStats {
  OBXSyncServerStats_connects = 1 , OBXSyncServerStats_messagesReceived = 2 , OBXSyncServerStats_messagesSent = 3 , OBXSyncServerStats_messageBytesReceived = 4 ,
  OBXSyncServerStats_messageBytesSent = 5 , OBXSyncServerStats_fullSyncs = 6 , OBXSyncServerStats_disconnectAborts = 7 , OBXSyncServerStats_clientTxsApplied = 8 ,
  OBXSyncServerStats_clientTxBytesApplied = 9 , OBXSyncServerStats_clientTxOpsApplied = 10 , OBXSyncServerStats_localTxsApplied = 11 , OBXSyncServerStats_asyncDbCommits = 12 ,
  OBXSyncServerStats_skippedTxDups = 13 , OBXSyncServerStats_loginSuccesses = 14 , OBXSyncServerStats_loginFailures = 15 , OBXSyncServerStats_loginFailuresUserBadCredentials = 16 ,
  OBXSyncServerStats_loginFailuresAuthUnavailable = 17 , OBXSyncServerStats_loginFailuresUserNoPermission = 18 , OBXSyncServerStats_messageSendFailures = 19 , OBXSyncServerStats_errorsProtocol = 20 ,
  OBXSyncServerStats_errorsInHandlers = 21 , OBXSyncServerStats_heartbeatFailures = 22 , OBXSyncServerStats_heartbeatsReceived = 23 , OBXSyncServerStats_historicUpdateTxsSent = 24 ,
  OBXSyncServerStats_newUpdateTxsSent = 25 , OBXSyncServerStats_forwardedMessagesReceived = 26 , OBXSyncServerStats_forwardedMessagesSent = 27 , OBXSyncServerStats_cacheGlobalToLocalHits = 28 ,
  OBXSyncServerStats_cacheGlobalToLocalMisses = 29 , OBXSyncServerStats_cacheGlobalToLocalSize = 30 , OBXSyncServerStats_cachePeerToLocalHits = 31 , OBXSyncServerStats_cachePeerToLocalMisses = 32 ,
  OBXSyncServerStats_cacheLocalToPeerHits = 33 , OBXSyncServerStats_cacheLocalToPeerMisses = 34 , OBXSyncServerStats_cachePeerSize = 35 , OBXSyncServerStats_clusterPeerState = 36 ,
  OBXSyncServerStats_clientTxsBehind = 37 , OBXSyncServerStats_clientTxsBehind_min = 38 , OBXSyncServerStats_clientTxsBehind_max = 39 , OBXSyncServerStats_connectedClients = 40 ,
  OBXSyncServerStats_connectedClients_min = 41 , OBXSyncServerStats_connectedClients_max = 42 , OBXSyncServerStats_queueLength = 43 , OBXSyncServerStats_queueLength_min = 44 ,
  OBXSyncServerStats_queueLength_max = 45 , OBXSyncServerStats_queueLengthAsync = 46 , OBXSyncServerStats_queueLengthAsync_min = 47 , OBXSyncServerStats_queueLengthAsync_max = 48 ,
  OBXSyncServerStats_txHistorySequence = 49 , OBXSyncServerStats_txHistorySequence_min = 50 , OBXSyncServerStats_txHistorySequence_max = 51
}
 Stats counter type IDs as passed to obx_sync_server_stats_u64() (for u64 values) and obx_sync_server_stats_f64() (for double (f64) values). More...
 
enum  OBXCustomMsgClientState { OBXCustomMsgClientState_Connecting = 1 , OBXCustomMsgClientState_Connected = 2 , OBXCustomMsgClientState_Disconnected = 3 }
 States of custom msg client that must be forwarded to obx_custom_msg_client_set_state(). More...
 

Functions

OBX_C_API OBX_syncobx_sync (OBX_store *store, const char *server_url)
 Creates a sync client associated with the given store and sync server URL. This does not initiate any connection attempts yet: call obx_sync_start() to do so. Before obx_sync_start(), you must configure credentials via obx_sync_credentials. By default a sync client automatically receives updates from the server once login succeeded. To configure this differently, call obx_sync_request_updates_mode() with the wanted mode. More...
 
OBX_C_API OBX_syncobx_sync_urls (OBX_store *store, const char *server_urls[], size_t server_urls_count)
 Creates a sync client associated with the given store and a list of sync server URL. For details, see obx_sync() More...
 
OBX_C_API obx_err obx_sync_close (OBX_sync *sync)
 Stops and closes (deletes) the sync client, freeing its resources. More...
 
OBX_C_API obx_err obx_sync_credentials (OBX_sync *sync, OBXSyncCredentialsType type, const void *data, size_t size)
 Sets credentials to authenticate the client with the server. See OBXSyncCredentialsType for available options. The accepted OBXSyncCredentials type depends on your sync-server configuration. More...
 
OBX_C_API obx_err obx_sync_credentials_user_password (OBX_sync *sync, OBXSyncCredentialsType type, const char *username, const char *password)
 Set username/password credentials to authenticate the client with the server. This is suitable for OBXSyncCredentialsType_OBX_ADMIN_USER and OBXSyncCredentialsType_USER_PASSWORD credential types. Use obx_sync_credentials() for other credential types. More...
 
OBX_C_API obx_err obx_sync_max_messages_in_flight (OBX_sync *sync, int value)
 Configures the maximum number of outgoing TX messages that can be sent without an ACK from the server. More...
 
OBX_C_API obx_err obx_sync_trigger_reconnect (OBX_sync *sync)
 Triggers a reconnection attempt immediately. By default, an increasing backoff interval is used for reconnection attempts. But sometimes the user of this API has additional knowledge and can initiate a reconnection attempt sooner. More...
 
OBX_C_API obx_err obx_sync_heartbeat_interval (OBX_sync *sync, uint64_t interval_ms)
 Sets the interval in which the client sends "heartbeat" messages to the server, keeping the connection alive. To detect disconnects early on the client side, you can also use heartbeats with a smaller interval. Use with caution, setting a low value (i.e. sending heartbeat very often) may cause an excessive network usage as well as high server load (with many clients). More...
 
OBX_C_API obx_err obx_sync_send_heartbeat (OBX_sync *sync)
 Triggers the heartbeat sending immediately. This lets you check the network connection at any time. More...
 
OBX_C_API obx_err obx_sync_request_updates_mode (OBX_sync *sync, OBXRequestUpdatesMode mode)
 Switches operation mode that's initialized after successful login Must be called before obx_sync_start() (returns OBX_ERROR_ILLEGAL_STATE if it was already started) More...
 
OBX_C_API obx_err obx_sync_start (OBX_sync *sync)
 Once the sync client is configured, you can "start" it to initiate synchronization. This method triggers communication in the background and will return immediately. If the synchronization destination is reachable, this background thread will connect to the server, log in (authenticate) and, depending on "update request mode", start syncing data. If the device, network or server is currently offline, connection attempts will be retried later using increasing backoff intervals. More...
 
OBX_C_API obx_err obx_sync_stop (OBX_sync *sync)
 Stops this sync client and thus stopping the synchronization. Does nothing if it is already stopped. More...
 
OBX_C_API OBXSyncState obx_sync_state (OBX_sync *sync)
 Gets the current state of the sync client (0 on error, e.g. given sync was NULL) More...
 
OBX_C_API obx_err obx_sync_wait_for_logged_in_state (OBX_sync *sync, uint64_t timeout_millis)
 Waits for the sync client to get into the given state or until the given timeout is reached. For an asynchronous alternative, please check the listeners. More...
 
OBX_C_API obx_err obx_sync_updates_request (OBX_sync *sync, bool subscribe_for_pushes)
 Request updates from the server since we last synced our database. More...
 
OBX_C_API obx_err obx_sync_updates_cancel (OBX_sync *sync)
 Cancel updates from the server (once received, the server stops sending updates). The counterpart to obx_sync_updates_request(). This should only be called in "logged in" state and there are no delivery guarantees given. More...
 
OBX_C_API obx_err obx_sync_outgoing_message_count (OBX_sync *sync, uint64_t limit, uint64_t *out_count)
 Count the number of messages in the outgoing queue, i.e. those waiting to be sent to the server. More...
 
OBX_C_API obx_err obx_sync_full (OBX_sync *sync)
 Experimental. This API is likely to be replaced/removed in a future version. Quickly bring our database up-to-date in a single transaction, without transmitting all the history. Good for initial sync of new clients. More...
 
OBX_C_API obx_err obx_sync_time_server (OBX_sync *sync, int64_t *out_timestamp_ns)
 Estimates the current server timestamp based on the last known server time and local steady clock. More...
 
OBX_C_API obx_err obx_sync_time_server_diff (OBX_sync *sync, int64_t *out_diff_ns)
 Returns the estimated difference between the server time and the local timestamp. Equivalent to calculating obx_sync_time_server() - "current time" (nanos since epoch). More...
 
OBX_C_API uint32_t obx_sync_protocol_version ()
 Gets the protocol version this client uses. More...
 
OBX_C_API uint32_t obx_sync_protocol_version_server (OBX_sync *sync)
 Gets the protocol version of the server after a connection is established (or attempted), zero otherwise. More...
 
OBX_C_API OBX_sync_msg_objects_builderobx_sync_msg_objects_builder (const void *topic, size_t topic_size)
 Start here to prepare an 'objects message'. Use obx_sync_msg_objects_builder_add() to set at least one object and then call obx_sync_send_msg_objects() or obx_sync_server_send_msg_objects() to initiate the sending process. More...
 
OBX_C_API obx_err obx_sync_msg_objects_builder_add (OBX_sync_msg_objects_builder *message, OBXSyncObjectType type, const void *data, size_t size, uint64_t id)
 Adds an object to the given message (builder). There must be at least one message before sending. More...
 
OBX_C_API obx_err obx_sync_msg_objects_builder_discard (OBX_sync_msg_objects_builder *message)
 Free the given message if you end up not sending it. Sending frees it already so never call this after obx_*_send(). More...
 
OBX_C_API obx_err obx_sync_send_msg_objects (OBX_sync *sync, OBX_sync_msg_objects_builder *message)
 Sends the given 'objects message' from the client to the currently connected server. More...
 
OBX_C_API void obx_sync_listener_connect (OBX_sync *sync, OBX_sync_listener_connect *listener, void *listener_arg)
 Set or overwrite a previously set 'connect' listener. More...
 
OBX_C_API void obx_sync_listener_disconnect (OBX_sync *sync, OBX_sync_listener_disconnect *listener, void *listener_arg)
 Set or overwrite a previously set 'disconnect' listener. More...
 
OBX_C_API void obx_sync_listener_login (OBX_sync *sync, OBX_sync_listener_login *listener, void *listener_arg)
 Set or overwrite a previously set 'login' listener. More...
 
OBX_C_API void obx_sync_listener_login_failure (OBX_sync *sync, OBX_sync_listener_login_failure *listener, void *listener_arg)
 Set or overwrite a previously set 'login failure' listener. More...
 
OBX_C_API void obx_sync_listener_complete (OBX_sync *sync, OBX_sync_listener_complete *listener, void *listener_arg)
 Set or overwrite a previously set 'complete' listener - notifies when the latest sync has finished. More...
 
OBX_C_API void obx_sync_listener_change (OBX_sync *sync, OBX_sync_listener_change *listener, void *listener_arg)
 Set or overwrite a previously set 'change' listener - provides information about incoming changes. More...
 
OBX_C_API void obx_sync_listener_server_time (OBX_sync *sync, OBX_sync_listener_server_time *listener, void *listener_arg)
 Set or overwrite a previously set 'serverTime' listener - provides current time updates from the sync-server. More...
 
OBX_C_API void obx_sync_listener_msg_objects (OBX_sync *sync, OBX_sync_listener_msg_objects *listener, void *listener_arg)
 Set or overwrite a previously set 'objects message' listener to receive application specific data objects. More...
 
OBX_C_API void obx_sync_listener_error (OBX_sync *sync, OBX_sync_listener_error *error, void *listener_arg)
 Set or overwrite a previously set 'error' listener - provides information about occurred sync-level errors. More...
 
OBX_C_API obx_err obx_sync_stats_u64 (OBX_sync *sync, OBXSyncStats counter_type, uint64_t *out_count)
 Get u64 value for sync statistics. More...
 
OBX_C_API OBX_sync_serverobx_sync_server (OBX_store_options *store_options, const char *url)
 Prepares an ObjectBox Sync Server to run within your application (embedded server) at the given URI. Note that you need a special sync edition, which includes the server components. Check https://objectbox.io/sync/. This call opens a store with the given options (also see obx_store_open()). The server's store is tied to the server itself and is closed when the server is closed. Before actually starting the server via obx_sync_server_start(), you can configure: More...
 
OBX_C_API OBX_sync_serverobx_sync_server_from_flat_options (OBX_store_options *store_options, const void *flat_options, size_t flat_options_size)
 Like obx_sync_server(), but retrieves its options for the Sync Server from the given FlatBuffers options. More...
 
OBX_C_API obx_err obx_sync_server_close (OBX_sync_server *server)
 Stops and closes (deletes) the sync server, freeing its resources. This includes the store associated with the server; it gets closed and must not be used anymore after this call. More...
 
OBX_C_API OBX_storeobx_sync_server_store (OBX_sync_server *server)
 Gets the store this server uses. This is owned by the server and must NOT be closed manually with obx_store_close(). More...
 
OBX_C_API obx_err obx_sync_server_certificate_path (OBX_sync_server *server, const char *certificate_path)
 Sets SSL certificate for the server to use. Use before obx_sync_server_start(). More...
 
OBX_C_API obx_err obx_sync_server_credentials (OBX_sync_server *server, OBXSyncCredentialsType type, const void *data, size_t size)
 Sets credentials for the server to accept. Use before obx_sync_server_start(). More...
 
OBX_C_API obx_err obx_sync_server_enable_auth (OBX_sync_server *server, OBXSyncCredentialsType type)
 Enables authenticator for server. Can be called multiple times. Use before obx_sync_server_start(). Use obx_sync_server_credentials() for authenticators which requires additional credentials data (i.e. Google Auth and shared secrets authenticators). More...
 
OBX_C_API obx_err obx_sync_server_worker_threads (OBX_sync_server *server, int thread_count)
 Sets the number of worker threads. Use before obx_sync_server_start(). More...
 
OBX_C_API obx_err obx_sync_server_history_max_size_in_kb (OBX_sync_server *server, uint64_t max_in_kb, uint64_t target_in_kb)
 Sets a maximum size for sync history entries to limit storage: old entries are removed to stay below this limit. Deleting older history entries may require clients to do a full sync if they have not contacted the server for a certain time. More...
 
OBX_C_API obx_err obx_sync_server_cluster_id (OBX_sync_server *server, const char *id)
 Configures the cluster ID for the given embedded server (the cluster feature must be enabled). More...
 
OBX_C_API obx_err obx_sync_server_add_cluster_peer (OBX_sync_server *server, const char *url, OBXSyncCredentialsType credentials_type, const void *credentials, size_t credentials_size, uint32_t flags)
 Adds a remote cluster peer that can be connected to using the given URL and credentials. Call this method multiple times to add multiple peers (at least 2 times for a cluster of 3). More...
 
OBX_C_API obx_err obx_sync_server_listener_change (OBX_sync_server *server, OBX_sync_listener_change *listener, void *listener_arg)
 Set or overwrite a previously set 'change' listener - provides information about incoming changes. More...
 
OBX_C_API obx_err obx_sync_server_listener_msg_objects (OBX_sync_server *server, OBX_sync_listener_msg_objects *listener, void *listener_arg)
 Set or overwrite a previously set 'objects message' listener to receive application specific data objects. More...
 
OBX_C_API obx_err obx_sync_server_start (OBX_sync_server *server)
 After the sync server is fully configured (e.g. credentials), this will actually start the server. Once this call returns, the server is ready to accept client connections. Also, port and URL will be available. More...
 
OBX_C_API obx_err obx_sync_server_stop (OBX_sync_server *server)
 Stops this sync server. Does nothing if it is already stopped. More...
 
OBX_C_API bool obx_sync_server_running (OBX_sync_server *server)
 Whether the server is up and running. More...
 
OBX_C_API const char * obx_sync_server_url (OBX_sync_server *server)
 Returns a URL this server is listening on, including the bound port (see obx_sync_server_port(). The returned char* is valid until another call to obx_sync_server_url() or the server is closed. More...
 
OBX_C_API uint16_t obx_sync_server_port (OBX_sync_server *server)
 Returns a port this server listens on. This is especially useful if the port was assigned arbitrarily (a "0" port was used in the URL given to obx_sync_server()). More...
 
OBX_C_API uint64_t obx_sync_server_connections (OBX_sync_server *server)
 Returns the number of clients connected to this server. More...
 
OBX_C_API obx_err obx_sync_server_stats_u64 (OBX_sync_server *server, OBXSyncServerStats counter_type, uint64_t *out_value)
 Get u64 value for sync server statistics. More...
 
OBX_C_API obx_err obx_sync_server_stats_f64 (OBX_sync_server *server, OBXSyncServerStats counter_type, double *out_value)
 Get double value for sync server statistics. More...
 
OBX_C_API const char * obx_sync_server_stats_string (OBX_sync_server *server, bool include_zero_values)
 Get server runtime statistics. The returned char* is valid until another call to obx_sync_server_stats_string() or the server is closed. More...
 
OBX_C_API obx_err obx_sync_server_send_msg_objects (OBX_sync_server *server, OBX_sync_msg_objects_builder *message)
 Broadcast the given 'objects message' from the server to all currently connected (and logged-in) clients. More...
 
OBX_C_API OBX_adminobx_sync_server_admin (OBX_sync_server *server, OBX_admin_options *options)
 Configure admin with a sync server, attaching the store and enabling custom sync-server functionality in the UI. This is a replacement for obx_admin_opt_store() and obx_admin_opt_store_path() - don't set them for the server. After configuring, this acts as obx_admin() - see for more details. You must use obx_admin_close() to stop & free resources after you're done; obx_sync_server_stop() doesn't do that. More...
 
OBX_C_API obx_err obx_custom_msg_server_register (const char *protocol, OBX_custom_msg_server_functions *functions, void *config_user_data)
 Must be called to register a protocol for a custom messaging server. Call before starting a server. More...
 
OBX_C_API uint64_t obx_custom_msg_server_add_client_connection (uint64_t server_id, void *user_data)
 Must be called from the custom server when a new client connection becomes available. More...
 
OBX_C_API obx_err obx_custom_msg_server_remove_client_connection (uint64_t server_id, uint64_t client_connection_id)
 Must be called from the custom server when a client connection becomes inactive (e.g. closed) and can be removed. More...
 
OBX_C_API obx_err obx_custom_msg_server_receive_message_from_client (uint64_t server_id, uint64_t client_connection_id, const void *message_data, size_t message_size)
 Must be called from the custom server when a message is received from a client connection. More...
 
OBX_C_API obx_err obx_custom_msg_client_register (const char *protocol, OBX_custom_msg_client_functions *functions, void *config_user_data)
 Must be called to register a protocol for your custom messaging client. Call before starting a client. More...
 
OBX_C_API obx_err obx_custom_msg_client_receive_message_from_server (uint64_t client_id, const void *message_data, size_t message_size)
 The custom msg client must call this whenever a message is received from the server. More...
 
OBX_C_API obx_err obx_custom_msg_client_set_state (uint64_t client_id, OBXCustomMsgClientState state)
 The custom msg client must call this whenever the state (according to given enum values) changes. More...
 
OBX_C_API obx_err obx_custom_msg_client_trigger_reconnect (uint64_t client_id)
 The custom msg client may call this if it has knowledge when a reconnection attempt makes sense, for example, when the network becomes available. More...
 

Detailed Description

Typedef Documentation

◆ OBX_custom_msg_client_func_clear_outgoing_messages

typedef void OBX_custom_msg_client_func_clear_outgoing_messages(void *client_user_data)

Callback to clear all outgoing messages. Must be provided to implement a custom client. See notes on OBX_custom_msg_client_functions for more details.

Parameters
client_user_datauser supplied data returned by the function that created the client

◆ OBX_custom_msg_client_func_connect

typedef bool OBX_custom_msg_client_func_connect(void *client_user_data)

Callback that tells the client it shall start trying to connect. Must be provided to implement a custom client. See notes on OBX_custom_msg_client_functions for more details.

Parameters
client_user_datauser supplied data returned by the function that created the client

◆ OBX_custom_msg_client_func_create

typedef void* OBX_custom_msg_client_func_create(uint64_t client_id, const char *url, const char *cert_path, void *config_user_data)

Callback to create a custom messaging client. Must be provided to implement a custom client. See notes on OBX_custom_msg_client_functions for more details.

Parameters
client_idthe ID that was assigned to the client instance
config_user_datauser provided data set at registration of the client
Returns
client user data, which will be passed on to the subsequent callbacks (OBX_custom_msg_client_func_*)
null to indicate an error that the client could not be created

◆ OBX_custom_msg_client_func_disconnect

typedef void OBX_custom_msg_client_func_disconnect(bool clear_outgoing_messages, void *client_user_data)

Callback that tells the client it shall disconnect. Must be provided to implement a custom client. See notes on OBX_custom_msg_client_functions for more details.

Parameters
client_user_datauser supplied data returned by the function that created the client

◆ OBX_custom_msg_client_func_join

typedef void OBX_custom_msg_client_func_join(void *client_user_data)

Must be provided to implement a custom client. See notes on OBX_custom_msg_client_functions for more details.

Parameters
client_user_datauser supplied data returned by the function that created the client

◆ OBX_custom_msg_client_func_send_async

typedef bool OBX_custom_msg_client_func_send_async(OBX_bytes_lazy *bytes, void *client_user_data)

Callback to enqueue a message for sending. Must be provided to implement a custom client. See notes on OBX_custom_msg_client_functions for more details.

Parameters
byteslazy bytes storing the message
client_user_datauser supplied data returned by the function that created the client

◆ OBX_custom_msg_client_func_shutdown

typedef void OBX_custom_msg_client_func_shutdown(void *client_user_data)

Callback to shut the custom client down, freeing its resources. The custom client is not used after this point. Must be provided to implement a custom client. See notes on OBX_custom_msg_client_functions for more details.

Parameters
client_user_datauser supplied data returned by the function that created the client

◆ OBX_custom_msg_client_func_start

typedef obx_err OBX_custom_msg_client_func_start(void *client_user_data)

Callback to start the client. Must be provided to implement a custom client. See notes on OBX_custom_msg_client_functions for more details.

Parameters
client_user_datauser supplied data returned by the function that created the client
Returns
OBX_SUCCESS if the client was successfully started
Any other fitting error code (OBX_ERROR_*) if the client could be started

◆ OBX_custom_msg_client_func_stop

typedef void OBX_custom_msg_client_func_stop(void *client_user_data)

Callback to stop and close the client (e.g. further messages delivery will be rejected). Must be provided to implement a custom client. See notes on OBX_custom_msg_client_functions for more details.

Parameters
client_user_datauser supplied data returned by the function that created the client

◆ OBX_custom_msg_client_functions

Struct of the custom client function callbacks. In order to implement the custom client, you must provide custom methods for each of the members of this struct. This is then passed to obx_custom_msg_client_register() to register the custom client.

◆ OBX_custom_msg_server_func_client_connection_close

typedef void OBX_custom_msg_server_func_client_connection_close(void *server_user_data, void *connection_user_data)

Callback to close the sync client connection to the custom server. Must be provided to implement a custom server. See notes on OBX_custom_msg_server_functions for more details.

Parameters
server_user_dataUser supplied data returned by the function that created the server

◆ OBX_custom_msg_server_func_client_connection_send_async

typedef bool OBX_custom_msg_server_func_client_connection_send_async(OBX_bytes_lazy *bytes, void *server_user_data, void *connection_user_data)

Callback to enqueue a message for sending. Must be provided to implement a custom server. See notes on OBX_custom_msg_server_functions for more details.

Parameters
byteslazy bytes storing the message
server_user_dataUser supplied data returned by the function that created the server

◆ OBX_custom_msg_server_func_client_connection_shutdown

typedef void OBX_custom_msg_server_func_client_connection_shutdown(void *connection_user_data)

Callback to shutdown and free all resources associated with the sync client connection to the custom server. Note that the custom server may already have been shutdown at this point (e.g. no server user data is supplied). Must be provided to implement a custom server. See notes on OBX_custom_msg_server_functions for more details.

Parameters
server_user_dataUser supplied data returned by the function that created the server

◆ OBX_custom_msg_server_func_create

typedef void* OBX_custom_msg_server_func_create(uint64_t server_id, const char *url, const char *cert_path, void *config_user_data)

Callback to create a custom messaging server. Must be provided to implement a custom server. See notes on OBX_custom_msg_server_functions for more details.

Parameters
server_idthe ID that was assigned to the custom server instance
config_user_datauser provided data set at registration of the server
Returns
server user data, which will be passed on to the subsequent callbacks (OBX_custom_msg_server_func_*)
null to indicate an error that the server could not be created

◆ OBX_custom_msg_server_func_shutdown

typedef void OBX_custom_msg_server_func_shutdown(void *server_user_data)

Callback to shut the custom server down, freeing its resources (the custom server is not used after this point). Must be provided to implement a custom server. See notes on OBX_custom_msg_server_functions for more details.

Parameters
server_user_dataUser supplied data returned by the function that created the server

◆ OBX_custom_msg_server_func_start

typedef obx_err OBX_custom_msg_server_func_start(void *server_user_data, uint64_t *out_port)

Callback to start a custom server. Must be provided to implement a custom server. See notes on OBX_custom_msg_server_functions for more details.

Parameters
server_user_dataUser supplied data returned by the function that created the server
out_portWhen starting, the custom server can optionally supply a port by writing to the given pointer. The port value is arbitrary and, for now, is only used for debug logs.
Returns
OBX_SUCCESS if the server was successfully started
Any other fitting error code (OBX_ERROR_*) if the server could be started

◆ OBX_custom_msg_server_func_stop

typedef void OBX_custom_msg_server_func_stop(void *server_user_data)

Callback to stop and close the custom server (e.g. further messages delivery will be rejected). Must be provided to implement a custom server. See notes on OBX_custom_msg_server_functions for more details. This includes the store associated with the server; it gets closed and must not be used anymore after this call.

Parameters
server_user_dataUser supplied data returned by the function that created the server

◆ OBX_custom_msg_server_functions

Struct of the custom server function callbacks. In order to implement the custom server, you must provide custom methods for each of the members of this struct. This is then passed to obx_custom_msg_server_register() to register the custom server.

◆ OBX_sync

typedef struct OBX_sync OBX_sync

◆ OBX_sync_change

◆ OBX_sync_change_array

◆ OBX_sync_listener_change

typedef void OBX_sync_listener_change(void *arg, const OBX_sync_change_array *changes)

Called with fine grained sync changes (IDs of put and removed entities)

Parameters
argis a pass-through argument passed to the called API

◆ OBX_sync_listener_complete

typedef void OBX_sync_listener_complete(void *arg)

Called when synchronization is complete.

Parameters
argis a pass-through argument passed to the called API

◆ OBX_sync_listener_connect

typedef void OBX_sync_listener_connect(void *arg)

Called when connection is established.

Parameters
argis a pass-through argument passed to the called API

◆ OBX_sync_listener_disconnect

typedef void OBX_sync_listener_disconnect(void *arg)

Called when connection is closed/lost.

Parameters
argis a pass-through argument passed to the called API

◆ OBX_sync_listener_error

typedef void OBX_sync_listener_error(void *arg, OBXSyncError error)

Callend when sync-level errors occur.

Parameters
argis a pass-through argument passed to the called API
errorerror code indicating sync-level error events

◆ OBX_sync_listener_login

typedef void OBX_sync_listener_login(void *arg)

Called on successful login.

Parameters
argis a pass-through argument passed to the called API

◆ OBX_sync_listener_login_failure

typedef void OBX_sync_listener_login_failure(void *arg, OBXSyncCode code)

Called on a login failure.

Parameters
argis a pass-through argument passed to the called API
codeerror code indicating why the login failed

◆ OBX_sync_listener_msg_objects

typedef void OBX_sync_listener_msg_objects(void *arg, const OBX_sync_msg_objects *msg_objects)

◆ OBX_sync_listener_server_time

typedef void OBX_sync_listener_server_time(void *arg, int64_t timestamp_ns)

Called when a server time information is received on the client.

Parameters
argis a pass-through argument passed to the called API
timestamp_nsis timestamp in nanoseconds since Unix epoch

◆ OBX_sync_msg_objects

Incubating message that carries multiple data "objects" (e.g. FlatBuffers, strings, raw bytes). Interpretation is up to the application. Does not involve any persistence or delivery guarantees at the moment.

◆ OBX_sync_msg_objects_builder

◆ OBX_sync_object

A single data object contained in a OBX_sync_msg_objects message.

◆ OBX_sync_server

Enumeration Type Documentation

◆ OBXCustomMsgClientState

States of custom msg client that must be forwarded to obx_custom_msg_client_set_state().

Enumerator
OBXCustomMsgClientState_Connecting 
OBXCustomMsgClientState_Connected 
OBXCustomMsgClientState_Disconnected 

◆ OBXRequestUpdatesMode

Enumerator
OBXRequestUpdatesMode_MANUAL 

no updates by default, obx_sync_updates_request() must be called manually

OBXRequestUpdatesMode_AUTO 

same as calling obx_sync_updates_request(sync, TRUE) default mode unless overridden by obx_sync_request_updates_mode

OBXRequestUpdatesMode_AUTO_NO_PUSHES 

same as calling obx_sync_updates_request(sync, FALSE)

◆ OBXSyncCode

Enumerator
OBXSyncCode_OK 
OBXSyncCode_REQ_REJECTED 
OBXSyncCode_CREDENTIALS_REJECTED 
OBXSyncCode_UNKNOWN 
OBXSyncCode_AUTH_UNREACHABLE 
OBXSyncCode_BAD_VERSION 
OBXSyncCode_CLIENT_ID_TAKEN 
OBXSyncCode_TX_VIOLATED_UNIQUE 

◆ OBXSyncCredentialsType

Specifies user-side credential types as well as server-side authenticator types. Some credential types do not make sense as authenticators such as OBXSyncCredentialsType_USER_PASSWORD which specifies a generic client-side credential type.

Enumerator
OBXSyncCredentialsType_NONE 
OBXSyncCredentialsType_SHARED_SECRET 
OBXSyncCredentialsType_GOOGLE_AUTH 
OBXSyncCredentialsType_SHARED_SECRET_SIPPED 
OBXSyncCredentialsType_OBX_ADMIN_USER 
OBXSyncCredentialsType_USER_PASSWORD 

◆ OBXSyncError

Sync-level error reporting codes, passed via obx_sync_listener_error().

Enumerator
OBXSyncError_REJECT_TX_NO_PERMISSION 

Sync client received rejection of transaction writes due to missing permissions. Until reconnecting with new credentials client will run in receive-only mode.

◆ OBXSyncObjectType

Enumerator
OBXSyncObjectType_FlatBuffers 
OBXSyncObjectType_String 
OBXSyncObjectType_Raw 

◆ OBXSyncServerStats

Stats counter type IDs as passed to obx_sync_server_stats_u64() (for u64 values) and obx_sync_server_stats_f64() (for double (f64) values).

Enumerator
OBXSyncServerStats_connects 

Total number of client connections established (u64)

OBXSyncServerStats_messagesReceived 

Total number of messages received from clients (u64)

OBXSyncServerStats_messagesSent 

Total number of messages sent to clients (u64)

OBXSyncServerStats_messageBytesReceived 

Total number of bytes received from clients via messages. (u64) Note: this is measured on the application level and thus may not match e.g. the network level.

OBXSyncServerStats_messageBytesSent 

Total number of bytes sent to clients via messages. (u64) Note: this is measured on the application level and thus may not match e.g. the network level. E.g. messages may be still enqueued so at least the timing will differ.

OBXSyncServerStats_fullSyncs 

Full syncs performed (u64)

OBXSyncServerStats_disconnectAborts 

Processing was aborted due to clients disconnected (u64)

OBXSyncServerStats_clientTxsApplied 

Total number of client transactions applied (u64)

OBXSyncServerStats_clientTxBytesApplied 

Total size in bytes of client transactions applied (u64)

OBXSyncServerStats_clientTxOpsApplied 

Total size in number of operations of transactions applied (u64)

OBXSyncServerStats_localTxsApplied 

Total number of local (server initiated) transactions applied (u64)

OBXSyncServerStats_asyncDbCommits 

AsyncQ committed TXs (u64)

OBXSyncServerStats_skippedTxDups 

Total number of skipped transactions duplicates (have been already applied before) (u64)

OBXSyncServerStats_loginSuccesses 

Total number of login successes (u64)

OBXSyncServerStats_loginFailures 

Total number of login failures (u64)

OBXSyncServerStats_loginFailuresUserBadCredentials 

Total number of login failures due to bad user credentials (u64)

OBXSyncServerStats_loginFailuresAuthUnavailable 

Total number of login failures due to authenticator not available (u64)

OBXSyncServerStats_loginFailuresUserNoPermission 

Total number of login failures due to user has no permissions (u64)

OBXSyncServerStats_messageSendFailures 

Total number of errors during message sending (u64)

OBXSyncServerStats_errorsProtocol 

Total number of protocol errors; e.g. offending clients (u64)

OBXSyncServerStats_errorsInHandlers 

Total number of errors in message handlers (u64)

OBXSyncServerStats_heartbeatFailures 

Total number of times a client has been disconnected due to heart failure (u64)

OBXSyncServerStats_heartbeatsReceived 

Total number of received client heartbeats (u64)

OBXSyncServerStats_historicUpdateTxsSent 

Total APPLY_TX messages HistoryPusher has sent out (u64)

OBXSyncServerStats_newUpdateTxsSent 

Total APPLY_TX messages newDataPusher has sent out (u64)

OBXSyncServerStats_forwardedMessagesReceived 

Total number of messages received from clients (u64)

OBXSyncServerStats_forwardedMessagesSent 

Total number of messages sent to clients (u64)

OBXSyncServerStats_cacheGlobalToLocalHits 

Total number of global-to-local cache hits (u64)

OBXSyncServerStats_cacheGlobalToLocalMisses 

Total number of global-to-local cache misses (u64)

OBXSyncServerStats_cacheGlobalToLocalSize 

Internal dev stat for ID Map caching (u64)

OBXSyncServerStats_cachePeerToLocalHits 

Internal dev stat for ID Map caching (u64)

OBXSyncServerStats_cachePeerToLocalMisses 

Internal dev stat for ID Map caching (u64)

OBXSyncServerStats_cacheLocalToPeerHits 

Internal dev stat for ID Map caching (u64)

OBXSyncServerStats_cacheLocalToPeerMisses 

Internal dev stat for ID Map caching (u64)

OBXSyncServerStats_cachePeerSize 

Internal dev stat for ID Map caching (u64)

OBXSyncServerStats_clusterPeerState 

Current cluster peer state (0 = unknown, 1 = leader, 2 = follower, 3 = candidate) (u64)

OBXSyncServerStats_clientTxsBehind 

Number of transactions between the current Tx and the oldest Tx currently ACKed on any client (current) (f64)

OBXSyncServerStats_clientTxsBehind_min 

Number of transactions between the current Tx and the oldest Tx currently ACKed on any client (minimum) (u64)

OBXSyncServerStats_clientTxsBehind_max 

Number of transactions between the current Tx and the oldest Tx currently ACKed on any client (maximum) (u64)

OBXSyncServerStats_connectedClients 

Number of connected clients (current) (f64)

OBXSyncServerStats_connectedClients_min 

Number of connected clients (minimum) (u64)

OBXSyncServerStats_connectedClients_max 

Number of connected clients (maximum) (u64)

OBXSyncServerStats_queueLength 

Length of the queue for regular Tasks (current) (f64)

OBXSyncServerStats_queueLength_min 

Length of the queue for regular Tasks (minimum) (u64)

OBXSyncServerStats_queueLength_max 

Length of the queue for regular Tasks (maximum) (u64)

OBXSyncServerStats_queueLengthAsync 

Length of the async queue (current) (f64)

OBXSyncServerStats_queueLengthAsync_min 

Length of the async queue (minimum) (u64)

OBXSyncServerStats_queueLengthAsync_max 

Length of the async queue (maximum) (u64)

OBXSyncServerStats_txHistorySequence 

Sequence number of TX log history (current) (f64)

OBXSyncServerStats_txHistorySequence_min 

Sequence number of TX log history (minimum) (u64)

OBXSyncServerStats_txHistorySequence_max 

Sequence number of TX log history (maximum) (u64)

◆ OBXSyncState

Enumerator
OBXSyncState_CREATED 
OBXSyncState_STARTED 
OBXSyncState_CONNECTED 
OBXSyncState_LOGGED_IN 
OBXSyncState_DISCONNECTED 
OBXSyncState_STOPPED 
OBXSyncState_DEAD 

◆ OBXSyncStats

Stats counter type IDs as passed to obx_sync_stats_u64().

Enumerator
OBXSyncStats_connects 

Total number of connects (u64)

OBXSyncStats_logins 

Total number of succesful logins (u64)

OBXSyncStats_messagesReceived 

Total number of messages received (u64)

OBXSyncStats_messagesSent 

Total number of messages sent (u64)

OBXSyncStats_messageSendFailures 

Total number of errors during message sending (u64)

OBXSyncStats_messageBytesReceived 

Total number of bytes received via messages. Note: this is measured on the application level and thus may not match e.g. the network level. (u64)

OBXSyncStats_messageBytesSent 

Total number of bytes sent via messages. Note: this is measured on the application level and thus may not match e.g. the network level. E.g. messages may be still enqueued so at least the timing will differ. (u64)

Function Documentation

◆ obx_custom_msg_client_receive_message_from_server()

OBX_C_API obx_err obx_custom_msg_client_receive_message_from_server ( uint64_t  client_id,
const void *  message_data,
size_t  message_size 
)

The custom msg client must call this whenever a message is received from the server.

Parameters
client_idthe ID that was assigned to the client instance
message_datathe message data in bytes
Returns
OBX_SUCCESS if the given message could be forwarded
OBX_NO_SUCCESS if no active client or active connection was found matching the given ID
OBX_ERROR_* in case the operation encountered an exceptional issue

◆ obx_custom_msg_client_register()

OBX_C_API obx_err obx_custom_msg_client_register ( const char *  protocol,
OBX_custom_msg_client_functions functions,
void *  config_user_data 
)

Must be called to register a protocol for your custom messaging client. Call before starting a client.

Parameters
protocolthe communication protocol to use, e.g. "tcp"
Returns
OBX_SUCCESS if the operation was successful
Any other fitting error code (OBX_ERROR_*) if the protocol could not be registered

◆ obx_custom_msg_client_set_state()

OBX_C_API obx_err obx_custom_msg_client_set_state ( uint64_t  client_id,
OBXCustomMsgClientState  state 
)

The custom msg client must call this whenever the state (according to given enum values) changes.

Parameters
client_idthe ID that was assigned to the client instance
statethe state to transition the custom client to
Returns
OBX_SUCCESS if the client was in a state that allowed the transition to the given state.
OBX_NO_SUCCESS if no active client or active connection was found matching the given ID.
OBX_NO_SUCCESS if no state transition was possible from the current to the given state (e.g. an internal "closed" state was reached).
OBX_ERROR_* in case the operation encountered an exceptional issue

◆ obx_custom_msg_client_trigger_reconnect()

OBX_C_API obx_err obx_custom_msg_client_trigger_reconnect ( uint64_t  client_id)

The custom msg client may call this if it has knowledge when a reconnection attempt makes sense, for example, when the network becomes available.

Parameters
client_idthe ID that was assigned to the client instance
Returns
OBX_SUCCESS if a reconnect was actually triggered.
OBX_NO_SUCCESS if no reconnect was triggered.
OBX_ERROR_* in case the operation encountered an exceptional issue

◆ obx_custom_msg_server_add_client_connection()

OBX_C_API uint64_t obx_custom_msg_server_add_client_connection ( uint64_t  server_id,
void *  user_data 
)

Must be called from the custom server when a new client connection becomes available.

Parameters
server_idthe ID that was assigned to the custom server instance
user_datauser provided data set at registration of custom server
Returns
a client connection ID that must be passed on to obx_custom_msg_server_receive_message_from_client().
0 in case the operation encountered an exceptional issue

◆ obx_custom_msg_server_receive_message_from_client()

OBX_C_API obx_err obx_custom_msg_server_receive_message_from_client ( uint64_t  server_id,
uint64_t  client_connection_id,
const void *  message_data,
size_t  message_size 
)

Must be called from the custom server when a message is received from a client connection.

Parameters
server_idthe ID that was assigned to the custom server instance
client_connection_idthe ID that was assigned to the custom client connection
message_datathe message data in bytes
Returns
OBX_SUCCESS if the operation was successful
OBX_NO_SUCCESS if no active server or active connection was found matching the given IDs
OBX_ERROR_* in case the operation encountered an exceptional issue

◆ obx_custom_msg_server_register()

OBX_C_API obx_err obx_custom_msg_server_register ( const char *  protocol,
OBX_custom_msg_server_functions functions,
void *  config_user_data 
)

Must be called to register a protocol for a custom messaging server. Call before starting a server.

Parameters
protocolthe communication protocol to use, e.g. "tcp"
functionsthe custom server function callbacks
config_user_datauser provided data set at registration of custom server
Returns
OBX_SUCCESS if the operation was successful
Any other fitting error code (OBX_ERROR_*) if the protocol could not be registered

◆ obx_custom_msg_server_remove_client_connection()

OBX_C_API obx_err obx_custom_msg_server_remove_client_connection ( uint64_t  server_id,
uint64_t  client_connection_id 
)

Must be called from the custom server when a client connection becomes inactive (e.g. closed) and can be removed.

Parameters
server_idthe ID that was assigned to the custom server instance
client_connection_idthe ID that was assigned to the custom client connection
Returns
OBX_SUCCESS if the operation was successful
OBX_NO_SUCCESS if no active server or active connection was found matching the given IDs
OBX_ERROR_* in case the operation encountered an exceptional issue

◆ obx_sync()

OBX_C_API OBX_sync* obx_sync ( OBX_store store,
const char *  server_url 
)

Creates a sync client associated with the given store and sync server URL. This does not initiate any connection attempts yet: call obx_sync_start() to do so. Before obx_sync_start(), you must configure credentials via obx_sync_credentials. By default a sync client automatically receives updates from the server once login succeeded. To configure this differently, call obx_sync_request_updates_mode() with the wanted mode.

◆ obx_sync_close()

OBX_C_API obx_err obx_sync_close ( OBX_sync sync)

Stops and closes (deletes) the sync client, freeing its resources.

◆ obx_sync_credentials()

OBX_C_API obx_err obx_sync_credentials ( OBX_sync sync,
OBXSyncCredentialsType  type,
const void *  data,
size_t  size 
)

Sets credentials to authenticate the client with the server. See OBXSyncCredentialsType for available options. The accepted OBXSyncCredentials type depends on your sync-server configuration.

Parameters
datamay be NULL in combination with OBXSyncCredentialsType_NONE

◆ obx_sync_credentials_user_password()

OBX_C_API obx_err obx_sync_credentials_user_password ( OBX_sync sync,
OBXSyncCredentialsType  type,
const char *  username,
const char *  password 
)

Set username/password credentials to authenticate the client with the server. This is suitable for OBXSyncCredentialsType_OBX_ADMIN_USER and OBXSyncCredentialsType_USER_PASSWORD credential types. Use obx_sync_credentials() for other credential types.

Parameters
typeshould be OBXSyncCredentialsType_OBX_ADMIN_USER or OBXSyncCredentialsType_USER_PASSWORD
Returns
OBX_ERROR_ILLEGAL_ARGUMENT if credential type does not support username/password authentication.

◆ obx_sync_full()

OBX_C_API obx_err obx_sync_full ( OBX_sync sync)

Experimental. This API is likely to be replaced/removed in a future version. Quickly bring our database up-to-date in a single transaction, without transmitting all the history. Good for initial sync of new clients.

Returns
OBX_SUCCESS if the request was likely sent (e.g. the sync client is in "logged in" state)
OBX_NO_SUCCESS if the request was not sent (and will not be sent in the future). Note: obx_last_error_code() is not set.

◆ obx_sync_heartbeat_interval()

OBX_C_API obx_err obx_sync_heartbeat_interval ( OBX_sync sync,
uint64_t  interval_ms 
)

Sets the interval in which the client sends "heartbeat" messages to the server, keeping the connection alive. To detect disconnects early on the client side, you can also use heartbeats with a smaller interval. Use with caution, setting a low value (i.e. sending heartbeat very often) may cause an excessive network usage as well as high server load (with many clients).

Parameters
interval_msinterval in milliseconds; the default is 25 minutes (1 500 000 milliseconds), which is also the allowed maximum.
Returns
OBX_ERROR_ILLEGAL_ARGUMENT if value is not in the allowed range, e.g. larger than the maximum (1 500 000).

◆ obx_sync_listener_change()

OBX_C_API void obx_sync_listener_change ( OBX_sync sync,
OBX_sync_listener_change listener,
void *  listener_arg 
)

Set or overwrite a previously set 'change' listener - provides information about incoming changes.

Parameters
listenerset NULL to reset
listener_argis a pass-through argument passed to the listener

◆ obx_sync_listener_complete()

OBX_C_API void obx_sync_listener_complete ( OBX_sync sync,
OBX_sync_listener_complete listener,
void *  listener_arg 
)

Set or overwrite a previously set 'complete' listener - notifies when the latest sync has finished.

Parameters
listenerset NULL to reset
listener_argis a pass-through argument passed to the listener

◆ obx_sync_listener_connect()

OBX_C_API void obx_sync_listener_connect ( OBX_sync sync,
OBX_sync_listener_connect listener,
void *  listener_arg 
)

Set or overwrite a previously set 'connect' listener.

Parameters
listenerset NULL to reset
listener_argis a pass-through argument passed to the listener

◆ obx_sync_listener_disconnect()

OBX_C_API void obx_sync_listener_disconnect ( OBX_sync sync,
OBX_sync_listener_disconnect listener,
void *  listener_arg 
)

Set or overwrite a previously set 'disconnect' listener.

Parameters
listenerset NULL to reset
listener_argis a pass-through argument passed to the listener

◆ obx_sync_listener_error()

OBX_C_API void obx_sync_listener_error ( OBX_sync sync,
OBX_sync_listener_error error,
void *  listener_arg 
)

Set or overwrite a previously set 'error' listener - provides information about occurred sync-level errors.

Parameters
listenerset NULL to reset
listener_argis a pass-through argument passed to the listener

◆ obx_sync_listener_login()

OBX_C_API void obx_sync_listener_login ( OBX_sync sync,
OBX_sync_listener_login listener,
void *  listener_arg 
)

Set or overwrite a previously set 'login' listener.

Parameters
listenerset NULL to reset
listener_argis a pass-through argument passed to the listener

◆ obx_sync_listener_login_failure()

OBX_C_API void obx_sync_listener_login_failure ( OBX_sync sync,
OBX_sync_listener_login_failure listener,
void *  listener_arg 
)

Set or overwrite a previously set 'login failure' listener.

Parameters
listenerset NULL to reset
listener_argis a pass-through argument passed to the listener

◆ obx_sync_listener_msg_objects()

OBX_C_API void obx_sync_listener_msg_objects ( OBX_sync sync,
OBX_sync_listener_msg_objects listener,
void *  listener_arg 
)

Set or overwrite a previously set 'objects message' listener to receive application specific data objects.

Parameters
listenerset NULL to reset
listener_argis a pass-through argument passed to the listener

◆ obx_sync_listener_server_time()

OBX_C_API void obx_sync_listener_server_time ( OBX_sync sync,
OBX_sync_listener_server_time listener,
void *  listener_arg 
)

Set or overwrite a previously set 'serverTime' listener - provides current time updates from the sync-server.

Parameters
listenerset NULL to reset
listener_argis a pass-through argument passed to the listener

◆ obx_sync_max_messages_in_flight()

OBX_C_API obx_err obx_sync_max_messages_in_flight ( OBX_sync sync,
int  value 
)

Configures the maximum number of outgoing TX messages that can be sent without an ACK from the server.

Returns
OBX_ERROR_ILLEGAL_ARGUMENT if value is not in the range 1-20

◆ obx_sync_msg_objects_builder()

OBX_C_API OBX_sync_msg_objects_builder* obx_sync_msg_objects_builder ( const void *  topic,
size_t  topic_size 
)

Start here to prepare an 'objects message'. Use obx_sync_msg_objects_builder_add() to set at least one object and then call obx_sync_send_msg_objects() or obx_sync_server_send_msg_objects() to initiate the sending process.

Parameters
topicoptional, application-specific message qualifier (may be NULL), usually a string but can also be binary

◆ obx_sync_msg_objects_builder_add()

OBX_C_API obx_err obx_sync_msg_objects_builder_add ( OBX_sync_msg_objects_builder message,
OBXSyncObjectType  type,
const void *  data,
size_t  size,
uint64_t  id 
)

Adds an object to the given message (builder). There must be at least one message before sending.

Parameters
idan optional (pass 0 if you don't need it) value that the application can use identify the object

◆ obx_sync_msg_objects_builder_discard()

OBX_C_API obx_err obx_sync_msg_objects_builder_discard ( OBX_sync_msg_objects_builder message)

Free the given message if you end up not sending it. Sending frees it already so never call this after obx_*_send().

◆ obx_sync_outgoing_message_count()

OBX_C_API obx_err obx_sync_outgoing_message_count ( OBX_sync sync,
uint64_t  limit,
uint64_t *  out_count 
)

Count the number of messages in the outgoing queue, i.e. those waiting to be sent to the server.

Parameters
limitpass 0 to count all messages without any limitation or a lower number that's enough for your app logic.
Note
This calls uses a (read) transaction internally: 1) it's not just a "cheap" return of a single number. While this will still be fast, avoid calling this function excessively. 2) the result follows transaction view semantics, thus it may not always match the actual value.

◆ obx_sync_protocol_version()

OBX_C_API uint32_t obx_sync_protocol_version ( )

Gets the protocol version this client uses.

◆ obx_sync_protocol_version_server()

OBX_C_API uint32_t obx_sync_protocol_version_server ( OBX_sync sync)

Gets the protocol version of the server after a connection is established (or attempted), zero otherwise.

◆ obx_sync_request_updates_mode()

OBX_C_API obx_err obx_sync_request_updates_mode ( OBX_sync sync,
OBXRequestUpdatesMode  mode 
)

Switches operation mode that's initialized after successful login Must be called before obx_sync_start() (returns OBX_ERROR_ILLEGAL_STATE if it was already started)

◆ obx_sync_send_heartbeat()

OBX_C_API obx_err obx_sync_send_heartbeat ( OBX_sync sync)

Triggers the heartbeat sending immediately. This lets you check the network connection at any time.

See also
obx_sync_heartbeat_interval()

◆ obx_sync_send_msg_objects()

OBX_C_API obx_err obx_sync_send_msg_objects ( OBX_sync sync,
OBX_sync_msg_objects_builder message 
)

Sends the given 'objects message' from the client to the currently connected server.

Parameters
messagethe prepared outgoing message; it will be freed along with any associated resources during this call (regardless of the call's success/failure outcome).
Returns
OBX_SUCCESS if the message was scheduled to be sent (no guarantees for actual sending/transmission given).
OBX_NO_SUCCESS if the message was not sent (no error will be set).
error code if an unexpected error occurred.

◆ obx_sync_server()

OBX_C_API OBX_sync_server* obx_sync_server ( OBX_store_options store_options,
const char *  url 
)

Prepares an ObjectBox Sync Server to run within your application (embedded server) at the given URI. Note that you need a special sync edition, which includes the server components. Check https://objectbox.io/sync/. This call opens a store with the given options (also see obx_store_open()). The server's store is tied to the server itself and is closed when the server is closed. Before actually starting the server via obx_sync_server_start(), you can configure:

  • accepted credentials via obx_sync_server_credentials() (always required)
  • SSL certificate info via obx_sync_server_certificate_path() (required if you use wss)
    Note
    The model given via store_options is also used to verify the compatibility of the models presented by clients. E.g. a client with an incompatible model will be rejected during login.
    Parameters
    store_optionsOptions for the server's store. It is freed automatically (same as with obx_store_open()) - don't use or free it afterwards.
    urlThe URL (following the pattern "protocol://IP:port") the server should listen on. Supported protocols are "ws" (WebSockets) and "wss" (secure WebSockets). To use the latter ("wss"), you must also call obx_sync_server_certificate_path(). To bind to all available interfaces, including those that are available from the "outside", use 0.0.0.0 as the IP. On the other hand, "127.0.0.1" is typically (may be OS dependent) only available on the same device. If you do not require a fixed port, use 0 (zero) as a port to tell the server to pick an arbitrary port that is available. The port can be queried via obx_sync_server_port() once the server was started. Examples: "ws://0.0.0.0:9999" could be used during development (WS no certificate config needed), while in a production system, you may want to use WSS and a specific IP for security reasons.
    See also
    obx_store_open()
    Returns
    NULL if server could not be created (e.g. the store could not be opened, bad URL, etc.)

◆ obx_sync_server_add_cluster_peer()

OBX_C_API obx_err obx_sync_server_add_cluster_peer ( OBX_sync_server server,
const char *  url,
OBXSyncCredentialsType  credentials_type,
const void *  credentials,
size_t  credentials_size,
uint32_t  flags 
)

Adds a remote cluster peer that can be connected to using the given URL and credentials. Call this method multiple times to add multiple peers (at least 2 times for a cluster of 3).

Parameters
urlURL to the remote cluster peer used to connect it.
flagsFor now, always pass 0.
credentialsthe credentials provided to the remote peer to login (it must match the remote's configuration). May be NULL in combination with OBXSyncCredentialsType_NONE.

◆ obx_sync_server_admin()

OBX_C_API OBX_admin* obx_sync_server_admin ( OBX_sync_server server,
OBX_admin_options options 
)

Configure admin with a sync server, attaching the store and enabling custom sync-server functionality in the UI. This is a replacement for obx_admin_opt_store() and obx_admin_opt_store_path() - don't set them for the server. After configuring, this acts as obx_admin() - see for more details. You must use obx_admin_close() to stop & free resources after you're done; obx_sync_server_stop() doesn't do that.

Parameters
optionsconfiguration set up with obx_admin_opt_*. You can pass NULL to use the default options.

◆ obx_sync_server_certificate_path()

OBX_C_API obx_err obx_sync_server_certificate_path ( OBX_sync_server server,
const char *  certificate_path 
)

Sets SSL certificate for the server to use. Use before obx_sync_server_start().

◆ obx_sync_server_close()

OBX_C_API obx_err obx_sync_server_close ( OBX_sync_server server)

Stops and closes (deletes) the sync server, freeing its resources. This includes the store associated with the server; it gets closed and must not be used anymore after this call.

◆ obx_sync_server_cluster_id()

OBX_C_API obx_err obx_sync_server_cluster_id ( OBX_sync_server server,
const char *  id 
)

Configures the cluster ID for the given embedded server (the cluster feature must be enabled).

Parameters
idA user defined string to identify the cluster (all cluster peer must share the same ID).

◆ obx_sync_server_connections()

OBX_C_API uint64_t obx_sync_server_connections ( OBX_sync_server server)

Returns the number of clients connected to this server.

◆ obx_sync_server_credentials()

OBX_C_API obx_err obx_sync_server_credentials ( OBX_sync_server server,
OBXSyncCredentialsType  type,
const void *  data,
size_t  size 
)

Sets credentials for the server to accept. Use before obx_sync_server_start().

Parameters
datamay be NULL in combination with OBXSyncCredentialsType_NONE

◆ obx_sync_server_enable_auth()

OBX_C_API obx_err obx_sync_server_enable_auth ( OBX_sync_server server,
OBXSyncCredentialsType  type 
)

Enables authenticator for server. Can be called multiple times. Use before obx_sync_server_start(). Use obx_sync_server_credentials() for authenticators which requires additional credentials data (i.e. Google Auth and shared secrets authenticators).

Parameters
typeshould be one of the available authentications, it should not be OBXSyncCredentialsType_USER_PASSWORD.

◆ obx_sync_server_from_flat_options()

OBX_C_API OBX_sync_server* obx_sync_server_from_flat_options ( OBX_store_options store_options,
const void *  flat_options,
size_t  flat_options_size 
)

Like obx_sync_server(), but retrieves its options for the Sync Server from the given FlatBuffers options.

Parameters
flat_optionsFlatBuffers serialized options for the server (start of the bytes buffer, not the "table").
flat_options_sizeSize of the FlatBuffers serialized options.

◆ obx_sync_server_history_max_size_in_kb()

OBX_C_API obx_err obx_sync_server_history_max_size_in_kb ( OBX_sync_server server,
uint64_t  max_in_kb,
uint64_t  target_in_kb 
)

Sets a maximum size for sync history entries to limit storage: old entries are removed to stay below this limit. Deleting older history entries may require clients to do a full sync if they have not contacted the server for a certain time.

Parameters
max_in_kbOnce this maximum size is reached, old history entries are deleted (default 0: no limit).
target_in_kbIf this value is non-zero, the deletion of old history entries is extended until reaching this target (lower than the maximum) allowing deletion "batching", which may be more efficient. If zero, the deletion stops already stops when reaching the max size (or lower).

◆ obx_sync_server_listener_change()

OBX_C_API obx_err obx_sync_server_listener_change ( OBX_sync_server server,
OBX_sync_listener_change listener,
void *  listener_arg 
)

Set or overwrite a previously set 'change' listener - provides information about incoming changes.

Parameters
listenerset NULL to reset
listener_argis a pass-through argument passed to the listener

◆ obx_sync_server_listener_msg_objects()

OBX_C_API obx_err obx_sync_server_listener_msg_objects ( OBX_sync_server server,
OBX_sync_listener_msg_objects listener,
void *  listener_arg 
)

Set or overwrite a previously set 'objects message' listener to receive application specific data objects.

Parameters
listenerset NULL to reset
listener_argis a pass-through argument passed to the listener

◆ obx_sync_server_port()

OBX_C_API uint16_t obx_sync_server_port ( OBX_sync_server server)

Returns a port this server listens on. This is especially useful if the port was assigned arbitrarily (a "0" port was used in the URL given to obx_sync_server()).

◆ obx_sync_server_running()

OBX_C_API bool obx_sync_server_running ( OBX_sync_server server)

Whether the server is up and running.

◆ obx_sync_server_send_msg_objects()

OBX_C_API obx_err obx_sync_server_send_msg_objects ( OBX_sync_server server,
OBX_sync_msg_objects_builder message 
)

Broadcast the given 'objects message' from the server to all currently connected (and logged-in) clients.

Parameters
messagethe prepared outgoing message; it will be freed along with any associated resources during this call (regardless of the call's success/failure outcome).
Returns
OBX_SUCCESS if the message was scheduled to be sent (no guarantees for actual sending/transmission given).
OBX_NO_SUCCESS if the message was not sent (no error will be set).
error code if an unexpected error occurred.

◆ obx_sync_server_start()

OBX_C_API obx_err obx_sync_server_start ( OBX_sync_server server)

After the sync server is fully configured (e.g. credentials), this will actually start the server. Once this call returns, the server is ready to accept client connections. Also, port and URL will be available.

◆ obx_sync_server_stats_f64()

OBX_C_API obx_err obx_sync_server_stats_f64 ( OBX_sync_server server,
OBXSyncServerStats  counter_type,
double *  out_value 
)

Get double value for sync server statistics.

Parameters
counter_typethe counter value to be read (make sure to use a double (f64) metric value type).
out_countreceives the counter value.
Returns
OBX_SUCCESS if the counter has been successfully retrieved.
OBX_ERROR_ILLEGAL_ARGUMENT if counter_type is undefined (this also happens if the wrong type is requested)
OBX_ERROR_ILLEGAL_STATE if the server is not started.

◆ obx_sync_server_stats_string()

OBX_C_API const char* obx_sync_server_stats_string ( OBX_sync_server server,
bool  include_zero_values 
)

Get server runtime statistics. The returned char* is valid until another call to obx_sync_server_stats_string() or the server is closed.

◆ obx_sync_server_stats_u64()

OBX_C_API obx_err obx_sync_server_stats_u64 ( OBX_sync_server server,
OBXSyncServerStats  counter_type,
uint64_t *  out_value 
)

Get u64 value for sync server statistics.

Parameters
counter_typethe counter value to be read (make sure to choose a uint64_t (u64) metric value type).
out_countreceives the counter value.
Returns
OBX_SUCCESS if the counter has been successfully retrieved.
OBX_ERROR_ILLEGAL_ARGUMENT if counter_type is undefined (this also happens if the wrong type is requested)
OBX_ERROR_ILLEGAL_STATE if the server is not started.

◆ obx_sync_server_stop()

OBX_C_API obx_err obx_sync_server_stop ( OBX_sync_server server)

Stops this sync server. Does nothing if it is already stopped.

◆ obx_sync_server_store()

OBX_C_API OBX_store* obx_sync_server_store ( OBX_sync_server server)

Gets the store this server uses. This is owned by the server and must NOT be closed manually with obx_store_close().

◆ obx_sync_server_url()

OBX_C_API const char* obx_sync_server_url ( OBX_sync_server server)

Returns a URL this server is listening on, including the bound port (see obx_sync_server_port(). The returned char* is valid until another call to obx_sync_server_url() or the server is closed.

◆ obx_sync_server_worker_threads()

OBX_C_API obx_err obx_sync_server_worker_threads ( OBX_sync_server server,
int  thread_count 
)

Sets the number of worker threads. Use before obx_sync_server_start().

Parameters
thread_countThe default is "0" which is hardware dependent, e.g. a multiple of CPU "cores".

◆ obx_sync_start()

OBX_C_API obx_err obx_sync_start ( OBX_sync sync)

Once the sync client is configured, you can "start" it to initiate synchronization. This method triggers communication in the background and will return immediately. If the synchronization destination is reachable, this background thread will connect to the server, log in (authenticate) and, depending on "update request mode", start syncing data. If the device, network or server is currently offline, connection attempts will be retried later using increasing backoff intervals.

◆ obx_sync_state()

OBX_C_API OBXSyncState obx_sync_state ( OBX_sync sync)

Gets the current state of the sync client (0 on error, e.g. given sync was NULL)

◆ obx_sync_stats_u64()

OBX_C_API obx_err obx_sync_stats_u64 ( OBX_sync sync,
OBXSyncStats  counter_type,
uint64_t *  out_count 
)

Get u64 value for sync statistics.

Parameters
counter_typethe counter value to be read.
out_countreceives the counter value.
Returns
OBX_SUCCESS if the counter has been successfully retrieved.
OBX_ERROR_ILLEGAL_ARGUMENT if counter_type is undefined.

◆ obx_sync_stop()

OBX_C_API obx_err obx_sync_stop ( OBX_sync sync)

Stops this sync client and thus stopping the synchronization. Does nothing if it is already stopped.

◆ obx_sync_time_server()

OBX_C_API obx_err obx_sync_time_server ( OBX_sync sync,
int64_t *  out_timestamp_ns 
)

Estimates the current server timestamp based on the last known server time and local steady clock.

Parameters
out_timestamp_ns- unix timestamp in nanoseconds - may be set to zero if the last server's time is unknown.

◆ obx_sync_time_server_diff()

OBX_C_API obx_err obx_sync_time_server_diff ( OBX_sync sync,
int64_t *  out_diff_ns 
)

Returns the estimated difference between the server time and the local timestamp. Equivalent to calculating obx_sync_time_server() - "current time" (nanos since epoch).

Parameters
out_diff_nstime difference in nanoseconds; e.g. positive if server time is ahead of local time. Set to 0 if there has not been a server contact yet and thus the server's time is unknown.

◆ obx_sync_trigger_reconnect()

OBX_C_API obx_err obx_sync_trigger_reconnect ( OBX_sync sync)

Triggers a reconnection attempt immediately. By default, an increasing backoff interval is used for reconnection attempts. But sometimes the user of this API has additional knowledge and can initiate a reconnection attempt sooner.

◆ obx_sync_updates_cancel()

OBX_C_API obx_err obx_sync_updates_cancel ( OBX_sync sync)

Cancel updates from the server (once received, the server stops sending updates). The counterpart to obx_sync_updates_request(). This should only be called in "logged in" state and there are no delivery guarantees given.

Returns
OBX_SUCCESS if the request was likely sent (e.g. the sync client is in "logged in" state)
OBX_NO_SUCCESS if the request was not sent (and will not be sent in the future). Note: obx_last_error_code() is not set.

◆ obx_sync_updates_request()

OBX_C_API obx_err obx_sync_updates_request ( OBX_sync sync,
bool  subscribe_for_pushes 
)

Request updates from the server since we last synced our database.

Parameters
subscribe_for_pusheskeep sending us future updates as they come in. This should only be called in "logged in" state and there are no delivery guarantees given.
Returns
OBX_SUCCESS if the request was likely sent (e.g. the sync client is in "logged in" state)
OBX_NO_SUCCESS if the request was not sent (and will not be sent in the future). Note: obx_last_error_code() is not set.

◆ obx_sync_urls()

OBX_C_API OBX_sync* obx_sync_urls ( OBX_store store,
const char *  server_urls[],
size_t  server_urls_count 
)

Creates a sync client associated with the given store and a list of sync server URL. For details, see obx_sync()

◆ obx_sync_wait_for_logged_in_state()

OBX_C_API obx_err obx_sync_wait_for_logged_in_state ( OBX_sync sync,
uint64_t  timeout_millis 
)

Waits for the sync client to get into the given state or until the given timeout is reached. For an asynchronous alternative, please check the listeners.

Parameters
timeout_millisMust be greater than 0
Returns
OBX_SUCCESS if the LOGGED_IN state has been reached within the given timeout
OBX_TIMEOUT if the given timeout was reached before a relevant state change was detected. Note: obx_last_error_code() is not set.
OBX_NO_SUCCESS if a state was reached within the given timeout that is unlikely to result in a successful login, e.g. "disconnected". Note: obx_last_error_code() is not set.