aboutsummaryrefslogtreecommitdiff
path: root/zenserver/zenserver.cpp
diff options
context:
space:
mode:
authorPer Larsson <[email protected]>2022-02-21 15:00:02 +0100
committerPer Larsson <[email protected]>2022-02-21 15:00:02 +0100
commit41782efc63d7f88525596d6724a1bb86d6fdcfa4 (patch)
tree80567b8cc256c361abb8f81b53680f2fa6ec6fcc /zenserver/zenserver.cpp
parentRefactored websocket message. (diff)
downloadzen-41782efc63d7f88525596d6724a1bb86d6fdcfa4.tar.xz
zen-41782efc63d7f88525596d6724a1bb86d6fdcfa4.zip
Added option to enable websockets.
Diffstat (limited to 'zenserver/zenserver.cpp')
-rw-r--r--zenserver/zenserver.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp
index 08abfdecd..78a62e202 100644
--- a/zenserver/zenserver.cpp
+++ b/zenserver/zenserver.cpp
@@ -205,7 +205,14 @@ public:
m_Http = zen::CreateHttpServer(ServerOptions.HttpServerClass);
int EffectiveBasePort = m_Http->Initialize(ServerOptions.BasePort);
- m_WebSocket = zen::WebSocketServer::Create();
+ if (ServerOptions.WebSocketPort != 0)
+ {
+ const uint32 ThreadCount =
+ ServerOptions.WebSocketThreads > 0 ? uint32_t(ServerOptions.WebSocketThreads) : std::thread::hardware_concurrency();
+
+ m_WebSocket = zen::WebSocketServer::Create(
+ {.Port = gsl::narrow<uint16_t>(ServerOptions.WebSocketPort), .ThreadCount = Max(ThreadCount, uint32_t(16))});
+ }
// Setup authentication manager
{
@@ -305,9 +312,13 @@ public:
m_Http->RegisterService(m_TestService); // NOTE: this is intentionally not limited to test mode as it's useful for diagnostics
m_Http->RegisterService(m_TestingService);
- m_WebSocket->RegisterService(m_TestingService);
m_Http->RegisterService(m_AdminService);
+ if (m_WebSocket)
+ {
+ m_WebSocket->RegisterService(m_TestingService);
+ }
+
if (m_HttpProjectService)
{
m_Http->RegisterService(*m_HttpProjectService);
@@ -400,7 +411,10 @@ public:
OnReady();
- m_WebSocket->Run({.Port = 8848});
+ if (m_WebSocket)
+ {
+ m_WebSocket->Run();
+ }
m_Http->Run(IsInteractiveMode);