-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGameClass2.cpp
More file actions
60 lines (48 loc) · 1.6 KB
/
GameClass2.cpp
File metadata and controls
60 lines (48 loc) · 1.6 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
#include <unistd.h>
#include <stdio.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <string.h>
#include <iostream>
#include "GameClass2.h"
GameClass2::GameClass2(int socket, ServerStats &serverStats) {
std::cout << "GC2 ctor" << std::endl;
this->socket = socket;
this->serverStats = serverStats;
}
GameClass2::~GameClass2() {
std::cout << "GC2 dtor" << std::endl;
}
int GameClass2::gameMenu() {
bool connected = true;
int readStatus;
while (connected) {
memset(buffer, 0, sizeof(buffer));
readStatus = read(socket, buffer, 1024);
if (readStatus == 0) {
connected = false;
}
// debug code:
std::cout << "Buffer reads \'" << buffer << "\', in Game2." << std::endl;
// Exit menu
if (strcmp(buffer , EXIT_MENU) == 0 ) {
connected = false;
std::cout << "BUGFIX server about to send" << std::endl;
send(socket , CONFIRMATION, strlen(CONFIRMATION) , 0);
std::cout << "BUGFIX server about to send" << std::endl;
}
// whatever you want
else if (strcmp(buffer, RPC_2) == 0 ) {
}
// check for disconnect rpc call.
else if (strcmp(buffer , DISCONNECT_RPC) == 0 ) {
return 1;
}
// else you need to return something
else {
return 0;
}
}
return 0;
}