1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 12:49:54 +00:00
openmw-tes3mp/apps/master/main.cpp

38 lines
765 B
C++
Raw Normal View History

2017-04-23 05:39:38 +00:00
#include <iostream>
#include <Kbhit.h>
#include <RakSleep.h>
#include "MasterServer.hpp"
2017-05-19 16:05:47 +00:00
#include "RestServer.hpp"
2017-04-23 05:39:38 +00:00
using namespace RakNet;
using namespace std;
2017-05-19 16:05:47 +00:00
unique_ptr<RestServer> restServer;
unique_ptr<MasterServer> masterServer;
bool run = true;
2017-04-23 05:39:38 +00:00
int main()
{
2017-05-19 16:05:47 +00:00
masterServer.reset(new MasterServer(2000, 25560));
restServer.reset(new RestServer(8080, masterServer->GetServers()));
auto onExit = [](int /*sig*/){
restServer->stop();
masterServer->Stop(false);
masterServer->Wait();
run = false;
};
signal(SIGINT, onExit);
signal(SIGTERM, onExit);
masterServer->Start();
thread server_thread([]() { restServer->start(); });
server_thread.join();
masterServer->Wait();
2017-04-23 05:39:38 +00:00
return 0;
}