RequestHandler: Reorder BroadcastCustomEvent

Code cleanup stuff
This commit is contained in:
tt2468 2021-12-13 19:20:27 -08:00
parent eb8d69dca5
commit 889062e44b
3 changed files with 30 additions and 30 deletions

View File

@ -23,8 +23,8 @@ const std::map<std::string, RequestMethodHandler> RequestHandler::_handlerMap
{ {
// General // General
{"GetVersion", &RequestHandler::GetVersion}, {"GetVersion", &RequestHandler::GetVersion},
{"BroadcastCustomEvent", &RequestHandler::BroadcastCustomEvent},
{"GetStats", &RequestHandler::GetStats}, {"GetStats", &RequestHandler::GetStats},
{"BroadcastCustomEvent", &RequestHandler::BroadcastCustomEvent},
{"GetHotkeyList", &RequestHandler::GetHotkeyList}, {"GetHotkeyList", &RequestHandler::GetHotkeyList},
{"TriggerHotkeyByName", &RequestHandler::TriggerHotkeyByName}, {"TriggerHotkeyByName", &RequestHandler::TriggerHotkeyByName},
{"TriggerHotkeyByKeySequence", &RequestHandler::TriggerHotkeyByKeySequence}, {"TriggerHotkeyByKeySequence", &RequestHandler::TriggerHotkeyByKeySequence},

View File

@ -45,8 +45,8 @@ class RequestHandler {
private: private:
// General // General
RequestResult GetVersion(const Request&); RequestResult GetVersion(const Request&);
RequestResult BroadcastCustomEvent(const Request&);
RequestResult GetStats(const Request&); RequestResult GetStats(const Request&);
RequestResult BroadcastCustomEvent(const Request&);
RequestResult GetHotkeyList(const Request&); RequestResult GetHotkeyList(const Request&);
RequestResult TriggerHotkeyByName(const Request&); RequestResult TriggerHotkeyByName(const Request&);
RequestResult TriggerHotkeyByKeySequence(const Request&); RequestResult TriggerHotkeyByKeySequence(const Request&);

View File

@ -58,34 +58,6 @@ RequestResult RequestHandler::GetVersion(const Request&)
return RequestResult::Success(responseData); return RequestResult::Success(responseData);
} }
/**
* Broadcasts a `CustomEvent` to all WebSocket clients. Receivers are clients which are identified and subscribed.
*
* @requestField eventData | Object | Data payload to emit to all receivers
*
* @requestType BroadcastCustomEvent
* @complexity 1
* @rpcVersion -1
* @initialVersion 5.0.0
* @category general
* @api requests
*/
RequestResult RequestHandler::BroadcastCustomEvent(const Request& request)
{
RequestStatus::RequestStatus statusCode;
std::string comment;
if (!request.ValidateObject("eventData", statusCode, comment))
return RequestResult::Error(statusCode, comment);
auto webSocketServer = GetWebSocketServer();
if (!webSocketServer)
return RequestResult::Error(RequestStatus::RequestProcessingFailed, "Unable to send event.");
webSocketServer->BroadcastEvent(EventSubscription::General, "CustomEvent", request.RequestData["eventData"]);
return RequestResult::Success();
}
/** /**
* Gets statistics about OBS, obs-websocket, and the current session. * Gets statistics about OBS, obs-websocket, and the current session.
* *
@ -118,6 +90,34 @@ RequestResult RequestHandler::GetStats(const Request&)
return RequestResult::Success(responseData); return RequestResult::Success(responseData);
} }
/**
* Broadcasts a `CustomEvent` to all WebSocket clients. Receivers are clients which are identified and subscribed.
*
* @requestField eventData | Object | Data payload to emit to all receivers
*
* @requestType BroadcastCustomEvent
* @complexity 1
* @rpcVersion -1
* @initialVersion 5.0.0
* @category general
* @api requests
*/
RequestResult RequestHandler::BroadcastCustomEvent(const Request& request)
{
RequestStatus::RequestStatus statusCode;
std::string comment;
if (!request.ValidateObject("eventData", statusCode, comment))
return RequestResult::Error(statusCode, comment);
auto webSocketServer = GetWebSocketServer();
if (!webSocketServer)
return RequestResult::Error(RequestStatus::RequestProcessingFailed, "Unable to send event.");
webSocketServer->BroadcastEvent(EventSubscription::General, "CustomEvent", request.RequestData["eventData"]);
return RequestResult::Success();
}
/** /**
* Gets an array of all hotkey names in OBS * Gets an array of all hotkey names in OBS
* *