WebSocketServer: Add parts for availableRequests/availableEvents

This commit is contained in:
tt2468 2021-04-30 10:13:42 -07:00
parent 45367a7355
commit df8ef87dc5
3 changed files with 14 additions and 1 deletions

View File

@ -138,6 +138,15 @@ WebSocketProtocol::ProcessResult WebSocketProtocol::ProcessMessage(SessionPtr se
return ret;
} else if (messageType == "Reidentify") {
std::unique_lock<std::mutex> 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;

View File

@ -19,4 +19,7 @@ namespace WebSocketProtocol {
};
ProcessResult ProcessMessage(SessionPtr session, json incomingMessage);
std::vector<std::string> GetRequestList();
std::vector<std::string> GetEventList();
}

View File

@ -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);