matrix-3ds-sdk/include/matrixclient.h

43 lines
1 KiB
C
Raw Normal View History

2019-10-16 18:39:57 +02:00
#ifndef _matrixclient_h_
#define _matrixclient_h_
#include <string>
#include <3ds.h>
#include <jansson.h>
2019-10-17 10:45:55 +02:00
namespace Matrix {
class Store {
public:
virtual void setSyncToken(std::string token) = 0;
virtual std::string getSyncToken() = 0;
};
class Client {
2019-10-16 18:39:57 +02:00
private:
2019-10-17 10:45:55 +02:00
public:
2019-10-16 18:39:57 +02:00
std::string hsUrl;
std::string token;
2019-10-17 10:45:55 +02:00
Store* store;
2019-10-17 12:54:49 +02:00
std::string userIdCache = "";
int requestId = 0;
bool stopSyncing = false;
Thread syncThread;
2019-10-17 10:45:55 +02:00
void processSync(json_t* sync);
json_t* doSync(std::string token);
json_t* doRequest(const char* method, std::string path, json_t* body = NULL);
2019-10-16 18:39:57 +02:00
public:
2019-10-17 10:45:55 +02:00
Client(std::string homeserverUrl, std::string matrixToken, Store* clientStore = NULL);
std::string userId();
2019-10-16 22:57:55 +02:00
std::string sendTextMessage(std::string roomId, std::string text);
std::string sendMessage(std::string roomId, json_t* content);
std::string sendEvent(std::string roomId, std::string eventType, json_t* content);
2019-10-17 12:54:49 +02:00
void startSyncLoop();
void stopSyncLoop();
void startSync();
2019-10-16 18:39:57 +02:00
};
2019-10-17 10:45:55 +02:00
}; // namespace Matrix
2019-10-16 18:39:57 +02:00
#endif // _matrixclient_h_