mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
Base: Nitpick cleanup for obs-websocket.cpp
This commit is contained in:
parent
91e3f5ee18
commit
0f303504e1
@ -16,8 +16,7 @@ WebSocketApi::Vendor *get_vendor(calldata_t *cd)
|
||||
return static_cast<WebSocketApi::Vendor*>(voidVendor);
|
||||
}
|
||||
|
||||
WebSocketApi::WebSocketApi(EventCallback cb) :
|
||||
_eventCallback(cb)
|
||||
WebSocketApi::WebSocketApi()
|
||||
{
|
||||
blog_debug("[WebSocketApi::WebSocketApi] Setting up...");
|
||||
|
||||
@ -50,6 +49,11 @@ WebSocketApi::~WebSocketApi()
|
||||
blog_debug("[WebSocketApi::~WebSocketApi] Finished.");
|
||||
}
|
||||
|
||||
void WebSocketApi::SetEventCallback(EventCallback cb)
|
||||
{
|
||||
_eventCallback = cb;
|
||||
}
|
||||
|
||||
enum WebSocketApi::RequestReturnCode WebSocketApi::PerformVendorRequest(std::string vendorName, std::string requestType, obs_data_t *requestData, obs_data_t *responseData)
|
||||
{
|
||||
std::shared_lock l(_mutex);
|
||||
@ -196,6 +200,9 @@ void WebSocketApi::vendor_event_emit_cb(void *priv_data, calldata_t *cd)
|
||||
|
||||
auto eventData = static_cast<obs_data_t*>(voidEventData);
|
||||
|
||||
if (!c->_eventCallback)
|
||||
RETURN_FAILURE();
|
||||
|
||||
c->_eventCallback(v->_name, eventType, eventData);
|
||||
|
||||
RETURN_SUCCESS();
|
||||
|
@ -25,9 +25,11 @@ class WebSocketApi {
|
||||
std::map<std::string, obs_websocket_request_callback> _requests;
|
||||
};
|
||||
|
||||
WebSocketApi(EventCallback cb);
|
||||
WebSocketApi();
|
||||
~WebSocketApi();
|
||||
|
||||
void SetEventCallback(EventCallback cb);
|
||||
|
||||
enum RequestReturnCode PerformVendorRequest(std::string vendorName, std::string requestName, obs_data_t *requestData, obs_data_t *responseData);
|
||||
|
||||
static void get_ph_cb(void *priv_data, calldata_t *cd);
|
||||
|
@ -56,7 +56,8 @@ bool obs_module_load(void)
|
||||
// Initialize event handler before server, as the server configures the event handler.
|
||||
_eventHandler = EventHandlerPtr(new EventHandler());
|
||||
|
||||
_webSocketApi = WebSocketApiPtr(new WebSocketApi(WebSocketApiEventCallback));
|
||||
_webSocketApi = WebSocketApiPtr(new WebSocketApi());
|
||||
_webSocketApi->SetEventCallback(WebSocketApiEventCallback);
|
||||
|
||||
_webSocketServer = WebSocketServerPtr(new WebSocketServer());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user