mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
RequestHandler: Reorder BroadcastCustomEvent
Code cleanup stuff
This commit is contained in:
parent
eb8d69dca5
commit
889062e44b
@ -23,8 +23,8 @@ const std::map<std::string, RequestMethodHandler> RequestHandler::_handlerMap
|
||||
{
|
||||
// General
|
||||
{"GetVersion", &RequestHandler::GetVersion},
|
||||
{"BroadcastCustomEvent", &RequestHandler::BroadcastCustomEvent},
|
||||
{"GetStats", &RequestHandler::GetStats},
|
||||
{"BroadcastCustomEvent", &RequestHandler::BroadcastCustomEvent},
|
||||
{"GetHotkeyList", &RequestHandler::GetHotkeyList},
|
||||
{"TriggerHotkeyByName", &RequestHandler::TriggerHotkeyByName},
|
||||
{"TriggerHotkeyByKeySequence", &RequestHandler::TriggerHotkeyByKeySequence},
|
||||
|
@ -45,8 +45,8 @@ class RequestHandler {
|
||||
private:
|
||||
// General
|
||||
RequestResult GetVersion(const Request&);
|
||||
RequestResult BroadcastCustomEvent(const Request&);
|
||||
RequestResult GetStats(const Request&);
|
||||
RequestResult BroadcastCustomEvent(const Request&);
|
||||
RequestResult GetHotkeyList(const Request&);
|
||||
RequestResult TriggerHotkeyByName(const Request&);
|
||||
RequestResult TriggerHotkeyByKeySequence(const Request&);
|
||||
|
@ -58,34 +58,6 @@ RequestResult RequestHandler::GetVersion(const Request&)
|
||||
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.
|
||||
*
|
||||
@ -118,6 +90,34 @@ RequestResult RequestHandler::GetStats(const Request&)
|
||||
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
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user