-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_server.cpp
42 lines (39 loc) · 1.3 KB
/
run_server.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
#include <thread>
#include "server.h"
int main(int argc, char *argv[]) {
QCoreApplication a(argc, argv);
model::database::local_connection();
auto *keeper = new network::queries_keeper; // TODO: delete keeper
auto *audio_keeper = new network::queries_keeper;
#ifdef LOCAL
server::server_socket receiver(QHostAddress::LocalHost, 1235, keeper);
server::server_socket audio_receiver(QHostAddress::LocalHost, 1236,
audio_keeper);
#else
server::server_socket receiver(QHostAddress::Any, 1235, keeper);
server::server_socket audio_receiver(QHostAddress::Any, 1236, audio_keeper);
#endif
server::server_processor processor(keeper, receiver);
server::audio_processor audio(audio_keeper, audio_receiver);
std::thread t([&processor, &a]() {
while (true) {
processor.wait_next_query();
if (processor.debug_terminate) {
qDebug() << "Dies from cringe";
a.quit();
}
}
});
t.detach();
std::thread t2([&audio, &a]() {
while (true) {
audio.wait_next_query();
if (audio.debug_terminate) {
qDebug() << "Dies from cringe";
a.quit();
}
}
});
t2.detach();
return a.exec();
}