GlosSITarget: Close existing target on launch

pull/212/head
Peter Repukat 1 year ago
parent be8e206683
commit 85ab663804

@ -21,7 +21,7 @@ limitations under the License.
#include "AppLauncher.h"
#include "Settings.h"
HttpServer::HttpServer(AppLauncher& app_launcher) : app_launcher_(app_launcher)
HttpServer::HttpServer(AppLauncher& app_launcher, std::function<void()> close) : app_launcher_(app_launcher), close_(close)
{
}
@ -62,6 +62,10 @@ void HttpServer::run()
res.set_content(j.dump(), "text/json");
});
server_.Post("/quit", [this](const httplib::Request& req, httplib::Response& res) {
close_();
});
server_.Get("/settings", [this](const httplib::Request& req, httplib::Response& res) {
res.set_content(Settings::toJson().dump(), "text/json");
});

@ -23,7 +23,7 @@ class AppLauncher;
class HttpServer {
public:
explicit HttpServer(AppLauncher& app_launcher);
explicit HttpServer(AppLauncher& app_launcher, std::function<void()> close);
void run();
void stop();
@ -34,4 +34,5 @@ class HttpServer {
uint16_t port_ = 8756;
AppLauncher& app_launcher_;
std::function<void()> close_;
};

@ -46,7 +46,7 @@ SteamTarget::SteamTarget()
delayed_shutdown_ = true;
delay_shutdown_clock_.restart();
}),
server_(launcher_)
server_(launcher_, [this] { run_ = false; })
{
target_window_handle_ = window_.getSystemHandle();
#ifdef _WIN32

@ -168,8 +168,9 @@ int main(int argc, char* argv[])
auto existingwindow = FindWindowA(nullptr, "GlosSITarget");
if (existingwindow) {
spdlog::error("GlosSITarget is already running!");
return 1;
spdlog::error("GlosSITarget is already running! Closing old process...");
httplib::Client client("http://localhost:8756");
client.Post("/quit");
}
int numArgs;

Loading…
Cancel
Save