From efadffb03b83360b1ebcb89505d4a23ea1239143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timmy=20Sj=C3=B6stedt?= Date: Sun, 19 Apr 2015 22:38:01 +0200 Subject: [PATCH] Spool up a HttpServer thread on script start --- rwgame/RWGame.cpp | 8 ++++++++ rwgame/RWGame.hpp | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/rwgame/RWGame.cpp b/rwgame/RWGame.cpp index bbb3818d..f693f218 100644 --- a/rwgame/RWGame.cpp +++ b/rwgame/RWGame.cpp @@ -4,6 +4,7 @@ #include "DrawUI.hpp" #include "ingamestate.hpp" #include "menustate.hpp" +#include "debug/HttpServer.hpp" #include #include @@ -153,6 +154,13 @@ void RWGame::startScript(const std::string& name) SCMFile* f = engine->data->loadSCM(name); if( f ) { if( script ) delete script; + + if ( ! httpserver) { + httpserver_thread = new std::thread([&](){ + httpserver = new HttpServer(this, engine); + httpserver->run(); + }); + } SCMOpcodes* opcodes = new SCMOpcodes; opcodes->modules.push_back(new VMModule); diff --git a/rwgame/RWGame.hpp b/rwgame/RWGame.hpp index 009a1fba..ffe37840 100644 --- a/rwgame/RWGame.hpp +++ b/rwgame/RWGame.hpp @@ -10,6 +10,8 @@ #include +class HttpServer; + class RWGame { Logger log; @@ -18,6 +20,8 @@ class RWGame // must be allocated after Logger setup. GameRenderer* renderer; ScriptMachine* script; + HttpServer* httpserver = nullptr; + std::thread* httpserver_thread = nullptr; sf::RenderWindow window; sf::Clock clock; bool inFocus;