30 lines
860 B
C++
30 lines
860 B
C++
#include "Web_Server.h"
|
|
|
|
#include "Renderive_WebSocket_Controller.h"
|
|
|
|
#include <drogon/drogon.h>
|
|
|
|
#include <algorithm>
|
|
#include <iostream>
|
|
#include <memory>
|
|
#include <thread>
|
|
|
|
namespace renderive::web {
|
|
|
|
int run_web_server(std::uint16_t port) {
|
|
const auto controller = std::make_shared<Renderive_WebSocket_Controller>();
|
|
const auto hardware_threads = std::max(2U, std::thread::hardware_concurrency());
|
|
std::cout << "Renderive WebSocket backend: ws://127.0.0.1:" << port
|
|
<< "/renderive\n"
|
|
<< "Open webapp/index.html directly; no HTTP application endpoint is used.\n";
|
|
drogon::app()
|
|
.registerController(controller)
|
|
.addListener("127.0.0.1", port)
|
|
.setThreadNum(std::min(8U, hardware_threads))
|
|
.setIdleConnectionTimeout(90)
|
|
.run();
|
|
return 0;
|
|
}
|
|
|
|
} // namespace renderive::web
|