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);
|
return static_cast<WebSocketApi::Vendor*>(voidVendor);
|
||||||
}
|
}
|
||||||
|
|
||||||
WebSocketApi::WebSocketApi(EventCallback cb) :
|
WebSocketApi::WebSocketApi()
|
||||||
_eventCallback(cb)
|
|
||||||
{
|
{
|
||||||
blog_debug("[WebSocketApi::WebSocketApi] Setting up...");
|
blog_debug("[WebSocketApi::WebSocketApi] Setting up...");
|
||||||
|
|
||||||
@ -50,6 +49,11 @@ WebSocketApi::~WebSocketApi()
|
|||||||
blog_debug("[WebSocketApi::~WebSocketApi] Finished.");
|
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)
|
enum WebSocketApi::RequestReturnCode WebSocketApi::PerformVendorRequest(std::string vendorName, std::string requestType, obs_data_t *requestData, obs_data_t *responseData)
|
||||||
{
|
{
|
||||||
std::shared_lock l(_mutex);
|
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);
|
auto eventData = static_cast<obs_data_t*>(voidEventData);
|
||||||
|
|
||||||
|
if (!c->_eventCallback)
|
||||||
|
RETURN_FAILURE();
|
||||||
|
|
||||||
c->_eventCallback(v->_name, eventType, eventData);
|
c->_eventCallback(v->_name, eventType, eventData);
|
||||||
|
|
||||||
RETURN_SUCCESS();
|
RETURN_SUCCESS();
|
||||||
|
@ -25,9 +25,11 @@ class WebSocketApi {
|
|||||||
std::map<std::string, obs_websocket_request_callback> _requests;
|
std::map<std::string, obs_websocket_request_callback> _requests;
|
||||||
};
|
};
|
||||||
|
|
||||||
WebSocketApi(EventCallback cb);
|
WebSocketApi();
|
||||||
~WebSocketApi();
|
~WebSocketApi();
|
||||||
|
|
||||||
|
void SetEventCallback(EventCallback cb);
|
||||||
|
|
||||||
enum RequestReturnCode PerformVendorRequest(std::string vendorName, std::string requestName, obs_data_t *requestData, obs_data_t *responseData);
|
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);
|
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.
|
// Initialize event handler before server, as the server configures the event handler.
|
||||||
_eventHandler = EventHandlerPtr(new EventHandler());
|
_eventHandler = EventHandlerPtr(new EventHandler());
|
||||||
|
|
||||||
_webSocketApi = WebSocketApiPtr(new WebSocketApi(WebSocketApiEventCallback));
|
_webSocketApi = WebSocketApiPtr(new WebSocketApi());
|
||||||
|
_webSocketApi->SetEventCallback(WebSocketApiEventCallback);
|
||||||
|
|
||||||
_webSocketServer = WebSocketServerPtr(new WebSocketServer());
|
_webSocketServer = WebSocketServerPtr(new WebSocketServer());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user