From df8ef87dc542e9eb2cc69ca4752d480d92d6fb23 Mon Sep 17 00:00:00 2001 From: tt2468 Date: Fri, 30 Apr 2021 10:13:42 -0700 Subject: [PATCH] WebSocketServer: Add parts for availableRequests/availableEvents --- src/WebSocketProtocol.cpp | 9 +++++++++ src/WebSocketProtocol.h | 3 +++ src/WebSocketServer.cpp | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/WebSocketProtocol.cpp b/src/WebSocketProtocol.cpp index f2ca3df3..ed114711 100644 --- a/src/WebSocketProtocol.cpp +++ b/src/WebSocketProtocol.cpp @@ -138,6 +138,15 @@ WebSocketProtocol::ProcessResult WebSocketProtocol::ProcessMessage(SessionPtr se return ret; } else if (messageType == "Reidentify") { std::unique_lock sessionLock(session->OperationMutex); + + WebSocketProtocol::ProcessResult parameterResult = SetSessionParameters(session, incomingMessage); + if (ret.closeCode != WebSocketServer::WebSocketCloseCode::DontClose) { + return parameterResult; + } + + ret.result["messageType"] = "Identified"; + ret.result["negotiatedRpcVersion"] = session->RpcVersion(); + return ret; } else { if (!session->IgnoreInvalidMessages()) { ret.closeCode = WebSocketServer::WebSocketCloseCode::UnknownMessageType; diff --git a/src/WebSocketProtocol.h b/src/WebSocketProtocol.h index 15dc50be..e4e6a32e 100644 --- a/src/WebSocketProtocol.h +++ b/src/WebSocketProtocol.h @@ -19,4 +19,7 @@ namespace WebSocketProtocol { }; ProcessResult ProcessMessage(SessionPtr session, json incomingMessage); + + std::vector GetRequestList(); + std::vector GetEventList(); } diff --git a/src/WebSocketServer.cpp b/src/WebSocketServer.cpp index 8307f60a..a8a57acb 100644 --- a/src/WebSocketServer.cpp +++ b/src/WebSocketServer.cpp @@ -276,7 +276,8 @@ void WebSocketServer::onOpen(websocketpp::connection_hdl hdl) helloMessage["messageType"] = "Hello"; helloMessage["obsWebSocketVersion"] = OBS_WEBSOCKET_VERSION; helloMessage["rpcVersion"] = OBS_WEBSOCKET_RPC_VERSION; - // todo: Add request and event lists + helloMessage["availableRequests"] = WebSocketProtocol::GetRequestList(); + helloMessage["availableEvents"] = WebSocketProtocol::GetEventList(); if (AuthenticationRequired) { std::string sessionChallenge = Utils::Crypto::GenerateSalt(); session->SetChallenge(sessionChallenge);