-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
46 lines (33 loc) · 1.09 KB
/
main.cpp
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
#include "MatrixClient.h"
#include <memory>
/**
* just an example and for testing
* purposes need a test account to test this
* with
* @param client
* @return
*/
auto run(std::shared_ptr<MatrixClient> client) -> boost::asio::awaitable<void> {
try {
co_await client->connect();
// Uncomment the desired login method
// Login with username and password
co_await client->password_login("testaccount", "password");
co_await client->long_polling();
// Login with token
//co_await client->token_login("your_login_token");
//std::cout << "Logged in successfully" << std::endl;
// Continue with other operations...
} catch (const std::exception& e) {
std::cerr << "Exception: " << e.what() << std::endl;
}
}
int main() {
std::string host = "matrix.org";
std::string port = "443";
boost::asio::io_context io_context;
auto client = std::make_shared<MatrixClient>(host, port, io_context);
boost::asio::co_spawn(io_context, run(client), boost::asio::detached);
io_context.run();
return 0;
}