mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
Move event emitting code
This commit is contained in:
@ -1505,6 +1505,25 @@ void WSEvents::OnStudioModeSwitched(bool checked) {
|
||||
broadcastUpdate("StudioModeSwitched", data);
|
||||
}
|
||||
|
||||
/**
|
||||
* A custom broadcast message was received
|
||||
*
|
||||
* @param {String} `realm` Identifier provided by the sender
|
||||
* @param {Object} `data` User-defined data
|
||||
*
|
||||
* @api events
|
||||
* @name BroadcastCustomMessage
|
||||
* @category general
|
||||
* @since 4.7.0
|
||||
*/
|
||||
void WSEvents::OnBroadcastCustomMessage(QString realm, OBSDataAutoRelease data) {
|
||||
OBSDataAutoRelease broadcastData = obs_data_create();
|
||||
obs_data_set_string(broadcastData, "realm", realm.toUtf8().constData());
|
||||
obs_data_set_obj(broadcastData, "data", data);
|
||||
|
||||
broadcastUpdate("BroadcastCustomMessage", broadcastData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {Object} `OBSStats`
|
||||
* @property {double} `fps` Current framerate.
|
||||
|
@ -49,8 +49,7 @@ public:
|
||||
const char* GetRecordingTimecode();
|
||||
obs_data_t* GetStats();
|
||||
|
||||
void broadcastUpdate(const char* updateType,
|
||||
obs_data_t* additionalFields);
|
||||
void OnBroadcastCustomMessage(QString realm, OBSDataAutoRelease data);
|
||||
|
||||
bool HeartbeatIsActive;
|
||||
|
||||
@ -73,6 +72,9 @@ private:
|
||||
uint64_t _lastBytesSent;
|
||||
uint64_t _lastBytesSentTime;
|
||||
|
||||
void broadcastUpdate(const char* updateType,
|
||||
obs_data_t* additionalFields);
|
||||
|
||||
void OnSceneChange();
|
||||
void OnSceneListChange();
|
||||
void OnSceneCollectionChange();
|
||||
|
@ -259,12 +259,7 @@ HandlerResponse WSRequestHandler::HandleBroadcastCustomMessage(WSRequestHandler*
|
||||
}
|
||||
|
||||
auto events = GetEventsSystem();
|
||||
|
||||
OBSDataAutoRelease broadcastData = obs_data_create();
|
||||
obs_data_set_string(broadcastData, "realm", realm.toUtf8().constData());
|
||||
obs_data_set_obj(broadcastData, "data", data);
|
||||
|
||||
events->broadcastUpdate("CustomMessage", broadcastData);
|
||||
events->OnBroadcastCustomMessage(realm, data);
|
||||
|
||||
return req->SendOKResponse();
|
||||
}
|
||||
|
Reference in New Issue
Block a user