-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
tdlua.h
71 lines (46 loc) · 1.2 KB
/
tdlua.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
* @author Giuseppe Marino
* ©Giuseppe Marino 2018 - 2018
* This file is under GPLv3 license see LICENCE
*/
#pragma once
#include <queue>
#include <map>
#include "json.hpp"
#ifdef TDLUA_CALLS
#include "LuaTDVoip.h"
#endif
class TDLua {
private:
void *tdjson;
std::queue<nlohmann::json> updates;
std::string dbpath;
#ifdef TDLUA_CALLS
std::map<int32_t, Call*> calls;
#endif
bool _ready;
public:
TDLua();
~TDLua();
void setTD(void* td);
void* getTD() const;
nlohmann::json pop();
void setDB(const std::string path);
void send(const nlohmann::json json) const;
nlohmann::json execute(const nlohmann::json json) const;
nlohmann::json receive(const size_t timeout = 10) const;
void push(const nlohmann::json update);
bool empty() const;
#ifdef TDLUA_CALLS
void setCall(const int32_t id, const Call* call);
void delCall(const int32_t id);
Call* getCall(const int32_t id) const;
void deinitAllCalls();
#endif
uint64_t runningCalls();
void saveUpdatesBuffer();
void loadUpdatesBuffer();
void emptyUpdatesBuffer();
void checkAuthState(const nlohmann::json update);
bool ready() const;
};