-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
71 lines (51 loc) · 2.54 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
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
#include <iostream>
#include "libfhraisepy_api.h"
#include "throwable.h"
auto lib = libfhraisepy_symbols();
auto root = lib->kotlin.root.xyz.xfqlittlefan.fhraise.py;
auto logger = root.Logger.Logger("libfhraise_test");
auto get_result() {
auto [pinned] = root.Message.Register.Result.Success._instance();
return pinned;
}
int main() {
const auto client = root.Client.Client("localhost", 11451);
Throwable *throwable_ptr;
root.Logger.debug(logger, "Connecting to the server.");
if (const auto connection_result = root.Client.connect(client, &throwable_ptr); !connection_result) {
auto [type, ref, message, stacktrace, stacktraceSize] = *throwable_ptr;
root.Logger.error(logger, "Error connecting to the server.");
root.Logger.error(logger, ("Error type: " + std::string(type)).c_str());
root.Logger.error(logger, ("Error message: " + std::string(message)).c_str());
for (int i = 0; i < stacktraceSize; ++i) {
root.Logger.error(logger, stacktrace[i]);
}
return 1;
}
root.Logger.debug(logger, "Receiving data from the server.");
while (true) {
char *message_type;
libfhraisepy_KNativePtr ref;
if (const auto receive = root.Client.receive(client, &message_type, &ref, &throwable_ptr,
reinterpret_cast<void *>(get_result));
!receive) {
auto [type, ref, message, stacktrace, stacktraceSize] = *throwable_ptr;
root.Logger.error(logger, "Error receiving data from the server.");
root.Logger.error(logger, ("Error type: " + std::string(type)).c_str());
root.Logger.error(logger, ("Error message: " + std::string(message)).c_str());
for (int i = 0; i < stacktraceSize; ++i) {
root.Logger.error(logger, stacktrace[i]);
}
return 1;
}
std::string message_type_string(message_type);
root.Logger.debug(logger, ("Received message type: " + message_type_string).c_str());
if (message_type_string == "xyz.xfqlittlefan.fhraise.py.Message.Register.Frame") {
const auto ref_frame = new libfhraisepy_kref_xyz_xfqlittlefan_fhraise_py_Message_Register_Frame(ref);
const auto call_id = root.Message.Register.Frame.get_callId(*ref_frame);
auto content = root.Message.Register.Frame.get_content(*ref_frame);
root.Logger.debug(logger, ("Received call ID: " + std::string(call_id)).c_str());
delete &ref_frame;
}
}
}