Agora C++ API Reference for All Platforms

Loading...
Searching...
No Matches
sync_client_i.h
1#pragma once
2#include "NGIAgoraSyncClient.h"
3#include <functional>
4 namespace agora {
5 namespace base {
6
10 class ISyncTransportObserver {
11 public:
12 virtual void onConnectResult(bool connected) = 0;
13 virtual void onDisconnected() = 0;
14 virtual void onError(int err) = 0;
15 virtual void onDataReceived(const char* data, size_t length) = 0;
16 virtual void OnTicketRefreshed(const char* key, const char* ticket) = 0;
17 virtual ~ISyncTransportObserver() {}
18};
19
20/* sync transport interface */
21 class ISyncTransport {
22 public:
23 virtual void connect(const char* token, const char* channelName, user_id_t uid) = 0;
24 virtual void disconnect() = 0;
25 virtual void sendBuffer(const char* data, size_t length) = 0;
26 virtual void renewTokenWithChannelInfo(const char* token, const char* channelName, user_id_t uid) {};
27 virtual void registerObserver(ISyncTransportObserver* observer) = 0;
28 virtual ~ISyncTransport() {}
29};
30 typedef std::function<void(SyncClientError, const char*, size_t, bool)> QueryCallbackFunc;
31 typedef std::function<void(SyncClientError, const char*)> DataBaseOpCallbackFunc;
32 typedef std::function<void(SyncClientError, const char*, const char*)> CollectionOpCallbackFunc;
33 class ISyncClientEx: public ISyncClient {
34 protected:
35 virtual ~ISyncClientEx() {}
36 public:
37
38 virtual int32_t registerExternalTransportLLApiInternal(ISyncTransport* transport) = 0;
39 virtual int32_t unregisterExternalTransportLLApiInternal(ISyncTransport* transport) = 0;
40 virtual int32_t registerSyncClientObserverLLApiInternal(ISyncClientObserver* observer, void(*safeDeleter)(ISyncClientObserver*) = nullptr) = 0;
41 virtual int32_t unregisterSyncClientObserverLLApiInternal(ISyncClientObserver* observer) = 0;
42 // client operations
43 virtual int32_t setRequestTimeoutLLApiInternal(const uint32_t timeout) = 0;
44 virtual int32_t setTicketLLApiInternal(const char* key, const char* ticket) = 0;
45 virtual int32_t removeTicketLLApiInternal(const char* channelId, user_id_t userId) = 0;
46 virtual int32_t renewTicketLLApiInternal(const char* key, const char* ticket) = 0;
47 virtual int32_t loginLLApiInternal(const char*token, const char* channelName, user_id_t userId, std::function<void(SyncClientError)> callback) = 0;
48 virtual int32_t queryDocLLApiInternal(const char* database, const char* coll, const char* range_start, const char* range_end, int64_t limits, bool doc_only, bool count_only, QueryCallbackFunc callback) = 0;
49 virtual int32_t logoutLLApiInternal() = 0;
50 virtual int32_t renewTokenLLApiInternal(const char* token) = 0;
51
52 // database operations
53 virtual int32_t connectDatabaseLLApiInternal(const char* database, DataBaseOpCallbackFunc callback) = 0;
54 virtual int32_t disconnectDatabaseLLApiInternal(const char* database,
55 DataBaseOpCallbackFunc callback) = 0;
56 virtual int32_t createCollectionLLApiInternal(const char* database, const char* collection,
57 const char** readable, int readSize,
58 CollectionOpCallbackFunc callback) = 0;
59 virtual int32_t deleteCollectionLLApiInternal(const char* database, const char* collection,
60 CollectionOpCallbackFunc callback) = 0;
61
62 // collection operations
63 virtual int32_t subscribeLLApiInternal(const char* database, const char* collection,
64 util::AString& snapshotJson) = 0;
65 virtual int32_t unsubscribeLLApiInternal(const char* database, const char* collection) = 0;
66 virtual int32_t addReadableLLApiInternal(const char* database, const char* coll, const char* readable) = 0;
67 virtual int32_t removeReadableLLApiInternal(const char* database, const char* coll, const char* readable) = 0;
68 virtual int32_t putDocLLApiInternal(const char* database, const char* collection,
69 const char* docName) = 0;
70 virtual int32_t deleteDocLLApiInternal(const char* database, const char* collection,
71 const char* docName) = 0;
72 virtual int32_t getDocsLLApiInternal(const char* database, const char* collection,
73 util::AString* docNames, uint32_t docSize) = 0;
74
75 // document operations
76 virtual int32_t putDocValueLLApiInternal(const char* database, const char* collection,
77 const char* docName, const char* jsonValue) = 0;
78 virtual int32_t updateDocValueLLApiInternal(const char* database, const char* collection,
79 const char* docName, const char* path,
80 const char* jsonValue) = 0;
81 virtual int32_t deleteDocValueLLApiInternal(const char* database, const char* collection,
82 const char* docName, const char* path) = 0;
83 virtual int32_t deleteDocValuesLLApiInternal(const char* database, const char* collection,
84 const char* docName, const char** path,
85 uint32_t pathSize) = 0;
86 virtual int32_t getDocValueLLApiInternal(const char* database, const char* collection,
87 const char* docName, util::AString& jsonValue) = 0;
88 virtual int32_t hasPathLLApiInternal(const char* database, const char* collection,
89 const char* docName, const char* path, bool& result) = 0;
90 virtual int32_t keepAliveDocLLApiInternal(const char* database, const char* collection,
91 const char* docName, uint32_t ttl) = 0;
92 virtual bool isOpPermissionLLApiInternal(const char* database, const char* collection,
93 const char* docName, OP_Privilege op) = 0;
94
95 // sync operations
96 virtual int32_t shakehandLLApiInternal() = 0;
97};
98
99}
100}
agora::base::ISyncClientEx
Definition sync_client_i.h:33
agora::base::ISyncClientEx::createCollectionLLApiInternal
virtual int32_t createCollectionLLApiInternal(const char *database, const char *collection, const char **readable, int readSize, CollectionOpCallbackFunc callback)=0
agora::base::ISyncClientEx::registerExternalTransportLLApiInternal
virtual int32_t registerExternalTransportLLApiInternal(ISyncTransport *transport)=0
agora::base::ISyncClientEx::getDocsLLApiInternal
virtual int32_t getDocsLLApiInternal(const char *database, const char *collection, util::AString *docNames, uint32_t docSize)=0
agora::base::ISyncClientEx::putDocLLApiInternal
virtual int32_t putDocLLApiInternal(const char *database, const char *collection, const char *docName)=0
agora::base::ISyncClientEx::unsubscribeLLApiInternal
virtual int32_t unsubscribeLLApiInternal(const char *database, const char *collection)=0
agora::base::ISyncClientEx::deleteDocValueLLApiInternal
virtual int32_t deleteDocValueLLApiInternal(const char *database, const char *collection, const char *docName, const char *path)=0
agora::base::ISyncClientEx::subscribeLLApiInternal
virtual int32_t subscribeLLApiInternal(const char *database, const char *collection, util::AString &snapshotJson)=0
agora::base::ISyncClientEx::getDocValueLLApiInternal
virtual int32_t getDocValueLLApiInternal(const char *database, const char *collection, const char *docName, util::AString &jsonValue)=0
agora::base::ISyncClientEx::disconnectDatabaseLLApiInternal
virtual int32_t disconnectDatabaseLLApiInternal(const char *database, DataBaseOpCallbackFunc callback)=0
agora::base::ISyncClientEx::unregisterSyncClientObserverLLApiInternal
virtual int32_t unregisterSyncClientObserverLLApiInternal(ISyncClientObserver *observer)=0
agora::base::ISyncClientEx::removeReadableLLApiInternal
virtual int32_t removeReadableLLApiInternal(const char *database, const char *coll, const char *readable)=0
agora::base::ISyncClientEx::renewTicketLLApiInternal
virtual int32_t renewTicketLLApiInternal(const char *key, const char *ticket)=0
agora::base::ISyncClientEx::hasPathLLApiInternal
virtual int32_t hasPathLLApiInternal(const char *database, const char *collection, const char *docName, const char *path, bool &result)=0
agora::base::ISyncClientEx::~ISyncClientEx
virtual ~ISyncClientEx()
Definition sync_client_i.h:35
agora::base::ISyncClientEx::shakehandLLApiInternal
virtual int32_t shakehandLLApiInternal()=0
agora::base::ISyncClientEx::deleteCollectionLLApiInternal
virtual int32_t deleteCollectionLLApiInternal(const char *database, const char *collection, CollectionOpCallbackFunc callback)=0
agora::base::ISyncClientEx::logoutLLApiInternal
virtual int32_t logoutLLApiInternal()=0
agora::base::ISyncClientEx::unregisterExternalTransportLLApiInternal
virtual int32_t unregisterExternalTransportLLApiInternal(ISyncTransport *transport)=0
agora::base::ISyncClientEx::deleteDocValuesLLApiInternal
virtual int32_t deleteDocValuesLLApiInternal(const char *database, const char *collection, const char *docName, const char **path, uint32_t pathSize)=0
agora::base::ISyncClientEx::registerSyncClientObserverLLApiInternal
virtual int32_t registerSyncClientObserverLLApiInternal(ISyncClientObserver *observer, void(*safeDeleter)(ISyncClientObserver *)=nullptr)=0
agora::base::ISyncClientEx::queryDocLLApiInternal
virtual int32_t queryDocLLApiInternal(const char *database, const char *coll, const char *range_start, const char *range_end, int64_t limits, bool doc_only, bool count_only, QueryCallbackFunc callback)=0
agora::base::ISyncClientEx::updateDocValueLLApiInternal
virtual int32_t updateDocValueLLApiInternal(const char *database, const char *collection, const char *docName, const char *path, const char *jsonValue)=0
agora::base::ISyncClientEx::deleteDocLLApiInternal
virtual int32_t deleteDocLLApiInternal(const char *database, const char *collection, const char *docName)=0
agora::base::ISyncClientEx::setTicketLLApiInternal
virtual int32_t setTicketLLApiInternal(const char *key, const char *ticket)=0
agora::base::ISyncClientEx::removeTicketLLApiInternal
virtual int32_t removeTicketLLApiInternal(const char *channelId, user_id_t userId)=0
agora::base::ISyncClientEx::renewTokenLLApiInternal
virtual int32_t renewTokenLLApiInternal(const char *token)=0
agora::base::ISyncClientEx::setRequestTimeoutLLApiInternal
virtual int32_t setRequestTimeoutLLApiInternal(const uint32_t timeout)=0
agora::base::ISyncClientEx::putDocValueLLApiInternal
virtual int32_t putDocValueLLApiInternal(const char *database, const char *collection, const char *docName, const char *jsonValue)=0
agora::base::ISyncClientEx::loginLLApiInternal
virtual int32_t loginLLApiInternal(const char *token, const char *channelName, user_id_t userId, std::function< void(SyncClientError)> callback)=0
agora::base::ISyncClientEx::keepAliveDocLLApiInternal
virtual int32_t keepAliveDocLLApiInternal(const char *database, const char *collection, const char *docName, uint32_t ttl)=0
agora::base::ISyncClientEx::isOpPermissionLLApiInternal
virtual bool isOpPermissionLLApiInternal(const char *database, const char *collection, const char *docName, OP_Privilege op)=0
agora::base::ISyncClientEx::connectDatabaseLLApiInternal
virtual int32_t connectDatabaseLLApiInternal(const char *database, DataBaseOpCallbackFunc callback)=0
agora::base::ISyncClientEx::addReadableLLApiInternal
virtual int32_t addReadableLLApiInternal(const char *database, const char *coll, const char *readable)=0
agora::base::ISyncClient
Definition NGIAgoraSyncClient.h:90
agora::base::ISyncClientObserver
Definition NGIAgoraSyncClient.h:61
agora::base::ISyncTransport
Definition sync_client_i.h:21
agora::base::ISyncTransport::~ISyncTransport
virtual ~ISyncTransport()
Definition sync_client_i.h:28
agora::base::ISyncTransport::disconnect
virtual void disconnect()=0
agora::base::ISyncTransport::registerObserver
virtual void registerObserver(ISyncTransportObserver *observer)=0
agora::base::ISyncTransport::sendBuffer
virtual void sendBuffer(const char *data, size_t length)=0
agora::base::ISyncTransport::connect
virtual void connect(const char *token, const char *channelName, user_id_t uid)=0
agora::base::ISyncTransport::renewTokenWithChannelInfo
virtual void renewTokenWithChannelInfo(const char *token, const char *channelName, user_id_t uid)
Definition sync_client_i.h:26
agora::base::ISyncTransportObserver
Definition sync_client_i.h:10
agora::base::ISyncTransportObserver::onError
virtual void onError(int err)=0
agora::base::ISyncTransportObserver::onDataReceived
virtual void onDataReceived(const char *data, size_t length)=0
agora::base::ISyncTransportObserver::~ISyncTransportObserver
virtual ~ISyncTransportObserver()
Definition sync_client_i.h:17
agora::base::ISyncTransportObserver::onConnectResult
virtual void onConnectResult(bool connected)=0
agora::base::ISyncTransportObserver::OnTicketRefreshed
virtual void OnTicketRefreshed(const char *key, const char *ticket)=0
agora::base::ISyncTransportObserver::onDisconnected
virtual void onDisconnected()=0
agora::base
Definition IAgoraService.h:73
agora::base::DataBaseOpCallbackFunc
std::function< void(SyncClientError, const char *)> DataBaseOpCallbackFunc
Definition sync_client_i.h:31
agora::base::OP_Privilege
OP_Privilege
Definition NGIAgoraSyncClient.h:53
agora::base::QueryCallbackFunc
std::function< void(SyncClientError, const char *, size_t, bool)> QueryCallbackFunc
Definition sync_client_i.h:30
agora::base::CollectionOpCallbackFunc
std::function< void(SyncClientError, const char *, const char *)> CollectionOpCallbackFunc
Definition sync_client_i.h:32
agora::base::SyncClientError
SyncClientError
Definition NGIAgoraSyncClient.h:17
agora::util::AString
CopyableAutoPtr< IString > AString
Definition AgoraBase.h:182
agora
Definition AgoraAtomicOps.h:21
agora::user_id_t
const char * user_id_t
Definition AgoraBase.h:849