forked from ExplosionEngine/Explosion
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWebUIServer.cpp
More file actions
38 lines (33 loc) · 1009 Bytes
/
WebUIServer.cpp
File metadata and controls
38 lines (33 loc) · 1009 Bytes
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
//
// Created by johnk on 2025/8/8.
//
#include <Editor/WebUIServer.h>
#include <Core/Cmdline.h>
static Core::CmdlineArgValue<uint32_t> caWebUIPort(
"webUIPort", "-webUIPort", 10907,
"WebUI port");
namespace Editor {
WebUIServer& WebUIServer::Get()
{
static WebUIServer webUIServer;
return webUIServer;
}
void WebUIServer::Start()
{
serverThread = std::make_unique<Common::NamedThread>("WebUIServerThread", [this]() -> void {
server = Common::MakeUnique<httplib::Server>();
server->set_mount_point("/", "./Web");
server->Get("/(.+)", [](const httplib::Request&, httplib::Response& res) {
res.set_file_content("./Web/index.html");
});
server->listen("localhost", caWebUIPort.GetValue());
});
}
void WebUIServer::Stop()
{
server->stop();
serverThread->Join();
server.Reset();
serverThread.Reset();
}
} // namespace Editor