-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcemuhookserver.h
62 lines (47 loc) · 1.37 KB
/
cemuhookserver.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
#include "cemuhookprotocol.h"
#include "config.h"
#include "crossSockets.h"
#include <cstddef>
#include <mutex>
#include <shared_mutex>
#include <thread>
#include <vector>
using namespace cemuhook_protocol;
class Server {
public:
Server();
Server(Config *c);
void Start();
void Stop();
~Server();
private:
struct Client {
sockaddr_in address;
uint32_t id;
int sendTimeout;
bool operator==(sockaddr_in const &other);
bool operator!=(sockaddr_in const &other);
};
Config *configStruct = nullptr;
uint serverPort = 26760;
std::vector<ConfiguredButton> configButtons;
bool stopServer = false;
bool stopSending = false;
int socketFd;
std::unique_ptr<std::thread> sendThread;
std::unique_ptr<std::thread> inputThread;
void sendTask();
void inputTask();
SharedResponse sharedResponse;
VersionInformation versionAnswer;
InfoAnswer infoAnswer;
InfoAnswer infoNoneAnswer;
DataEvent dataAnswer;
void PrepareAnswerConstants();
// std::pair<uint16_t, void const *> PrepareVersionAnswer(uint32_t const &id);
std::pair<uint16_t, void const *> PrepareInfoAnswer(uint8_t const &slot);
std::pair<uint16_t, void const *> PrepareDataAnswer(uint32_t const &packet);
void CalcCrcDataAnswer();
std::vector<Client> clients;
void handleClientsTimeout();
};