forked from CV-IP/DeepGTAV
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Server.h
41 lines (32 loc) · 777 Bytes
/
Server.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
#pragma once
#include "Scenario.h"
#include <WinSock2.h>
#include <WS2tcpip.h>
// Need to link with Ws2_32.lib
#pragma comment (lib, "ws2_32")
class Server {
private:
WSADATA wsaData;
u_long iMode = 1; //non-blocking socket
SOCKET ServerSocket = INVALID_SOCKET;
SOCKET ClientSocket = INVALID_SOCKET;
bool sendOutputs = false;
int bytesRead = 0;
int recvMessageLen = 0;
int sendMessageLen = 0;
bool readyToSend = false;
bool frameSent = false;
char json[4096];
StringBuffer message;
const char* chmessage;
int messageSize = 0;
std::clock_t lastSentMessage = std::clock();
void resetState();
public:
bool clientConnected = false;
Scenario scenario;
Server(unsigned int port);
void checkRecvMessage();
void checkSendMessage();
void checkClient();
};