diff --git a/src/WSRequestHandler.cpp b/src/WSRequestHandler.cpp index c6bd5166..153812ab 100644 --- a/src/WSRequestHandler.cpp +++ b/src/WSRequestHandler.cpp @@ -132,7 +132,7 @@ QSet WSRequestHandler::authNotRequired { "Authenticate" }; -WSRequestHandler::WSRequestHandler(QSharedPointer connProperties) : +WSRequestHandler::WSRequestHandler(QVariantHash& connProperties) : _messageId(0), _requestType(""), data(nullptr), @@ -174,7 +174,7 @@ HandlerResponse WSRequestHandler::processRequest(std::string& textMessage){ if (Config::Current()->AuthRequired && (!authNotRequired.contains(_requestType)) - && (_connProperties->value(PROP_AUTHENTICATED).toBool() == false)) + && (_connProperties.value(PROP_AUTHENTICATED).toBool() == false)) { return SendErrorResponse("Not Authenticated"); } diff --git a/src/WSRequestHandler.h b/src/WSRequestHandler.h index 1ef1bb3f..a5f1b410 100644 --- a/src/WSRequestHandler.h +++ b/src/WSRequestHandler.h @@ -36,7 +36,7 @@ class WSRequestHandler : public QObject { Q_OBJECT public: - explicit WSRequestHandler(QSharedPointer connProperties); + explicit WSRequestHandler(QVariantHash& connProperties); ~WSRequestHandler(); std::string processIncomingMessage(std::string& textMessage); bool hasField(QString name); @@ -44,7 +44,7 @@ class WSRequestHandler : public QObject { private: const char* _messageId; const char* _requestType; - QSharedPointer _connProperties; + QVariantHash& _connProperties; OBSDataAutoRelease data; HandlerResponse processRequest(std::string& textMessage); diff --git a/src/WSRequestHandler_General.cpp b/src/WSRequestHandler_General.cpp index a9f1598e..5a6b97f0 100644 --- a/src/WSRequestHandler_General.cpp +++ b/src/WSRequestHandler_General.cpp @@ -82,7 +82,7 @@ HandlerResponse WSRequestHandler::HandleAuthenticate(WSRequestHandler* req) { return req->SendErrorResponse("missing request parameters"); } - if (req->_connProperties->value(PROP_AUTHENTICATED).toBool() == true) { + if (req->_connProperties.value(PROP_AUTHENTICATED).toBool() == true) { return req->SendErrorResponse("already authenticated"); } @@ -95,7 +95,7 @@ HandlerResponse WSRequestHandler::HandleAuthenticate(WSRequestHandler* req) { return req->SendErrorResponse("Authentication Failed."); } - req->_connProperties->insert(PROP_AUTHENTICATED, true); + req->_connProperties.insert(PROP_AUTHENTICATED, true); return req->SendOKResponse(); } diff --git a/src/WSServer.cpp b/src/WSServer.cpp index 5f4486bd..386ff554 100644 --- a/src/WSServer.cpp +++ b/src/WSServer.cpp @@ -142,7 +142,7 @@ void WSServer::broadcast(std::string message) QMutexLocker locker(&_clMutex); for (connection_hdl hdl : _connections) { if (Config::Current()->AuthRequired) { - bool authenticated = _connectionProperties[hdl]->value(PROP_AUTHENTICATED).toBool(); + bool authenticated = _connectionProperties[hdl].value(PROP_AUTHENTICATED).toBool(); if (!authenticated) { continue; } @@ -155,7 +155,7 @@ void WSServer::onOpen(connection_hdl hdl) { QMutexLocker locker(&_clMutex); _connections.insert(hdl); - _connectionProperties[hdl] = QSharedPointer(new QVariantHash()); + _connectionProperties[hdl] = QVariantHash(); locker.unlock(); QString clientIp = getRemoteEndpoint(hdl); @@ -174,13 +174,16 @@ void WSServer::onMessage(connection_hdl hdl, server::message_ptr message) std::string payload = message->get_payload(); QMutexLocker locker(&_clMutex); - auto connProperties = _connectionProperties[hdl]; + QVariantHash& connProperties = _connectionProperties[hdl]; locker.unlock(); WSRequestHandler handler(connProperties); std::string response = handler.processIncomingMessage(payload); _server.send(hdl, response, websocketpp::frame::opcode::text); + + boost::atomic atomicTest; + atomicTest.load().insert("jambon", true); }); } diff --git a/src/WSServer.h b/src/WSServer.h index 4bb8bfde..5d97af1f 100644 --- a/src/WSServer.h +++ b/src/WSServer.h @@ -18,14 +18,14 @@ with this program. If not, see #pragma once +#include +#include #include #include #include #include #include - -#include -#include +#include #include #include @@ -73,7 +73,7 @@ private: server _server; quint16 _serverPort; std::set> _connections; - std::map, std::owner_less> _connectionProperties; + std::map> _connectionProperties; QMutex _clMutex; QThreadPool _threadPool; };