-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
70 lines (61 loc) · 1.95 KB
/
main.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
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
//
// Created by alpar on 7.09.2019.
//
#include "resources/Server.h"
#include "resources/Client.h"
bool isServer = true;
int main() {
if(isServer)
{
Server *trying = new Server("192.168.2.231", 8080);
trying->startListen();
trying->createGame(100);
trying->connectionHandlerEvent();
}else
{
Client *trying = new Client("192.168.2.231", 8080);
trying->createConnection();
long ptr = trying->receiveData();
trying->sendData("USER,FIRSTINFO", 14);
trying->receiveData();
cout << trying->receiveMessage() << endl;
trying->sendData("ME,INFO", 7);
trying->receiveData();
cout << trying->receiveMessage() << endl;
/*
trying->sendData("ME", 2);
if (trying->receiveData() > 0)
{
cout << trying->receiveMessage();
}
else
{
}
int i = 0;
while(i < 10)
{
cout << "Sending Message to Server : Hello Server \n";
trying->sendData("Hello Server", 13);
ptr = trying->receiveData();
if(ptr < 0)
{
cout << "There is no Data/Packet Received";
cout << "Server :" << trying->receiveMessage() << endl;
}else
{
cout << "Server :" << trying->receiveMessage() << endl;
}
i++;
trying->sendData("Count", 6);
ptr = trying->receiveData();
cout << "Server :" << trying->receiveMessage() << endl;
Sleep(1000);
}
cout << "Sending Message Successful Now Closing Connection \n";
trying->sendData("123", 5);
trying->closeConnection();
*/
}
getch();
return 0;
}