-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
46 lines (37 loc) · 871 Bytes
/
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
#include <iostream>
#include <fstream>
#include "pistache/router.h"
#include "REST/AIHandler.h"
string getTokenFromFile(const char fileName[6]);
using Net::Address;
using std::string;
using std::ifstream;
int main(int argc, char** argv) {
string ip = "127.0.0.1";
string port = "9080";
if (argc > 1) {
// Ip is given.
ip = argv[1];
}
if (argc > 2) {
// Port is given.
port = argv[2];
}
Net::Port p((uint16_t) std::stoi(port));
Address addr(ip.c_str(), p);
AIHandler ch(addr);
// Set token from file.
ch.getBeach().setToken(getTokenFromFile("token"));
ch.init(3);
ch.start();
ch.shutdown();
return 0;
}
string getTokenFromFile(const char fileName[6]) {
string token;
ifstream file;
file.open(fileName);
file >> token;
file.close();
return token;
}