mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
[Master] Enable RestAPI
This commit is contained in:
parent
ec6614ba32
commit
17af679c07
1 changed files with 24 additions and 16 deletions
|
@ -2,29 +2,37 @@
|
|||
#include <Kbhit.h>
|
||||
#include <RakSleep.h>
|
||||
#include "MasterServer.hpp"
|
||||
#include "RestServer.hpp"
|
||||
|
||||
using namespace RakNet;
|
||||
using namespace std;
|
||||
|
||||
unique_ptr<RestServer> restServer;
|
||||
unique_ptr<MasterServer> masterServer;
|
||||
bool run = true;
|
||||
|
||||
int main()
|
||||
{
|
||||
MasterServer masterServer(2000, 25560);
|
||||
masterServer.reset(new MasterServer(2000, 25560));
|
||||
restServer.reset(new RestServer(8080, masterServer->GetServers()));
|
||||
|
||||
masterServer.Start();
|
||||
auto onExit = [](int /*sig*/){
|
||||
restServer->stop();
|
||||
masterServer->Stop(false);
|
||||
masterServer->Wait();
|
||||
run = false;
|
||||
};
|
||||
|
||||
signal(SIGINT, onExit);
|
||||
signal(SIGTERM, onExit);
|
||||
signal(SIGSTOP, onExit);
|
||||
|
||||
masterServer->Start();
|
||||
|
||||
thread server_thread([]() { restServer->start(); });
|
||||
|
||||
server_thread.join();
|
||||
masterServer->Wait();
|
||||
|
||||
/*while(true)
|
||||
{
|
||||
if(kbhit())
|
||||
{
|
||||
if(getch() == 'e')
|
||||
{
|
||||
cout << endl;
|
||||
masterServer.Stop(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
RakSleep(100);
|
||||
}*/
|
||||
masterServer.Wait();
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue