This repository was archived by the owner on Jun 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
61 lines (41 loc) · 1.24 KB
/
main.cpp
File metadata and controls
61 lines (41 loc) · 1.24 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
#include <iostream>
#include <list>
#include <SDL2/SDL.h>
#include <SDL2/SDL_net.h>
#include <exception>
#include <fstream>
#include "Server.h"
void serverReaction(Server* server, ClientInfo* info) {
ServerInfo* send = new ServerInfo();
send->clientName = info->name;
send->message = new std::string(*info->message);
send->clientID = info->ID;
send->message_type = NEW_MESSAGE;
if (info->message->c_str() == SHUTDOWN_SIGNAL)
server->setShutdownStatus(true);
else
server->sendToClient(send);
delete send;
std::ofstream file;
file.open("output.txt");
file << std::to_string(info->servoDegree) << std::endl;
file << std::to_string(info->speed);
file.close();
std::cout << "servoDegree : ";
std::cout << info->servoDegree << std::endl;
}
int main(int argc, char** argv) {
if (SDLNet_Init() == -1)
std::cout << "Error : " << SDLNet_GetError() << std::endl;
Server *server = new Server(8889, 512, 5, serverReaction, "server");
try {
while (!server->getShutdownStatus()) {
server->checkForConnections();
server->checkForActivity();
}
}
catch (std::exception& e) {
std::cout << e.what();
}
return 0;
}