diff --git a/CMakeLists.txt b/CMakeLists.txt index a68b491a..16d495d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,7 +62,7 @@ find_package(LibObs REQUIRED) # Find Qt5 -find_package(Qt5 REQUIRED COMPONENTS Core Widgets Svg Concurrent Network) +find_package(Qt5 REQUIRED COMPONENTS Core Widgets Svg Network) # Find nlohmann @@ -115,6 +115,7 @@ set(obs-websocket_SOURCES src/utils/Json.cpp src/utils/Obs.cpp src/utils/Platform.cpp + src/utils/Compat.cpp deps/qr/cpp/QrCode.cpp) set(obs-websocket_HEADERS @@ -134,6 +135,7 @@ set(obs-websocket_HEADERS src/utils/Json.h src/utils/Obs.h src/utils/Platform.h + src/utils/Compat.h src/utils/Utils.h deps/qr/cpp/QrCode.hpp) @@ -148,7 +150,6 @@ include_directories( ${Qt5Core_INCLUDES} ${Qt5Widgets_INCLUDES} ${Qt5Svg_INCLUDES} - ${Qt5Concurrent_INCLUDES} ${Qt5Network_INCLUDES} "${CMAKE_SOURCE_DIR}/deps/asio/asio/include" "${CMAKE_SOURCE_DIR}/deps/websocketpp") @@ -158,7 +159,6 @@ target_link_libraries(obs-websocket Qt5::Core Qt5::Widgets Qt5::Svg - Qt5::Concurrent Qt5::Network nlohmann_json::nlohmann_json) diff --git a/src/WebSocketServer.cpp b/src/WebSocketServer.cpp index d67562b9..6619da85 100644 --- a/src/WebSocketServer.cpp +++ b/src/WebSocketServer.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -11,6 +10,7 @@ #include "Config.h" #include "utils/Crypto.h" #include "utils/Platform.h" +#include "utils/Compat.h" WebSocketServer::WebSocketServer() : QObject(nullptr), @@ -269,6 +269,9 @@ void WebSocketServer::onOpen(websocketpp::connection_hdl hdl) // Log connection blog(LOG_INFO, "[WebSocketServer::onOpen] New WebSocket client has connected from %s", session->RemoteAddress().c_str()); + if (_debugEnabled) + blog(LOG_INFO, "[WebSocketServer::onOpen] Sending Op 0 (Hello) message:\n%s", helloMessage.dump(2).c_str()); + // Send object to client websocketpp::lib::error_code errorCode; auto sessionEncoding = session->Encoding(); @@ -338,7 +341,7 @@ void WebSocketServer::onMessage(websocketpp::connection_hdl hdl, websocketpp::se { auto opcode = message->get_opcode(); std::string payload = message->get_payload(); - QtConcurrent::run(&_threadPool, [=]() { + _threadPool.start(Utils::Compat::CreateFunctionRunnable([=]() { std::unique_lock lock(_sessionMutex); SessionPtr session; try { @@ -445,5 +448,5 @@ skipProcessing: if (errorCode) blog(LOG_WARNING, "[WebSocketServer::onMessage] Sending message to client failed: %s", errorCode.message().c_str()); } - }); + })); } diff --git a/src/WebSocketServer_Protocol.cpp b/src/WebSocketServer_Protocol.cpp index 66ba4771..aa4fea96 100644 --- a/src/WebSocketServer_Protocol.cpp +++ b/src/WebSocketServer_Protocol.cpp @@ -1,4 +1,3 @@ -#include #include #include "WebSocketServer.h" @@ -8,6 +7,7 @@ #include "Config.h" #include "utils/Crypto.h" #include "utils/Platform.h" +#include "utils/Compat.h" namespace WebSocketOpCode { enum WebSocketOpCode: uint8_t { @@ -261,7 +261,7 @@ void WebSocketServer::BroadcastEvent(uint64_t requiredIntent, std::string eventT if (!_server.is_listening()) return; - QtConcurrent::run(&_threadPool, [=]() { + _threadPool.start(Utils::Compat::CreateFunctionRunnable([=]() { // Populate message object json eventMessage; eventMessage["op"] = 5; @@ -309,5 +309,5 @@ void WebSocketServer::BroadcastEvent(uint64_t requiredIntent, std::string eventT lock.unlock(); if (_debugEnabled && (EventSubscription::All & requiredIntent) != 0) // Don't log high volume events blog(LOG_INFO, "[WebSocketServer::BroadcastEvent] Outgoing event:\n%s", eventMessage.dump(2).c_str()); - }); + })); }