-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient.hpp
More file actions
93 lines (67 loc) · 1.66 KB
/
Client.hpp
File metadata and controls
93 lines (67 loc) · 1.66 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#pragma once
#include <winsock2.h>
#include <thread>
#include <vector>
#include <atomic>
#include <string>
#include <cstdint>
#include <openssl/ssl.h>
#include "pugixml.hpp"
#include "JID.hpp"
#include "Iq.hpp"
#include "Channels.hpp"
#include "Profile.hpp"
struct st_mysql;
struct ssl_st;
struct ssl_ctx_st;
using MYSQL = st_mysql;
using SSL = ssl_st;
using SSL_CTX = ssl_ctx_st;
#define PORT 5222
#define BUFFER_SIZE 1024
enum BasicPackets : int
{
STREAMSTREAM = 0,
TLSSTART = 1,
AUTH = 2,
IQ = 3
};
#pragma pack(push, 1)
struct PacketHeader
{
uint32_t magic;
uint64_t length;
};
#pragma pack(pop)
class Client
{
public:
explicit Client(SOCKET socket);
~Client() = default;
void start();
bool sendAll(SOCKET s, const char* data, int len);
bool sendPacket(SOCKET s, const std::vector<char>& data);
bool recvAll(SOCKET s, char* buf, int len);
void sendMessage(const std::string& msg);
//bool GetProfile(int64_t user_id);
void StreamStream(Client* client);
bool TLS();
bool UserExists(MYSQL* conn,
int64_t user_id,
const std::string& token);
bool IsAuthorized = false;
bool tlsEnabled = false;
BasicPackets count = STREAMSTREAM;
SSL* g_ssl = nullptr;
SSL_CTX* g_ctx = nullptr;
Jid* JID = NULL;
IqClass* Iq = NULL;
uint64_t UserID = 0;
SOCKET clientSocket;
Channels* Channel = NULL;
Player* Player = NULL;
private:
std::thread clientThread;
std::atomic<bool> isRunning{ true };
void handle();
};