mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
General: Toggle to log outgoing response and events
This commit is contained in:
parent
b57982b6cb
commit
7675a1ee58
11
WSEvents.cpp
11
WSEvents.cpp
@ -20,6 +20,7 @@ with this program. If not, see <https://www.gnu.org/licenses/>
|
|||||||
#include <util/platform.h>
|
#include <util/platform.h>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include "Config.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "WSEvents.h"
|
#include "WSEvents.h"
|
||||||
#include "obs-websocket.h"
|
#include "obs-websocket.h"
|
||||||
@ -213,9 +214,15 @@ void WSEvents::broadcastUpdate(const char* updateType, obs_data_t* additionalFie
|
|||||||
if (additionalFields != NULL)
|
if (additionalFields != NULL)
|
||||||
obs_data_apply(update, additionalFields);
|
obs_data_apply(update, additionalFields);
|
||||||
|
|
||||||
_srv->broadcast(obs_data_get_json(update));
|
const char *json = obs_data_get_json(update);
|
||||||
|
|
||||||
obs_data_release(update);
|
obs_data_release(update);
|
||||||
|
|
||||||
|
if (Config::Current()->DebugEnabled)
|
||||||
|
{
|
||||||
|
blog(LOG_DEBUG, "Update << '%s'", json);
|
||||||
|
}
|
||||||
|
|
||||||
|
_srv->broadcast(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WSEvents::connectTransitionSignals(obs_source_t* transition)
|
void WSEvents::connectTransitionSignals(obs_source_t* transition)
|
||||||
|
@ -117,7 +117,7 @@ void WSRequestHandler::processIncomingMessage(QString textMessage)
|
|||||||
|
|
||||||
if (Config::Current()->DebugEnabled)
|
if (Config::Current()->DebugEnabled)
|
||||||
{
|
{
|
||||||
blog(LOG_INFO, ">> '%s'", msg);
|
blog(LOG_DEBUG, "Request >> '%s'", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasField("request-type") ||
|
if (!hasField("request-type") ||
|
||||||
@ -161,9 +161,7 @@ void WSRequestHandler::SendOKResponse(obs_data_t* additionalFields)
|
|||||||
if (additionalFields)
|
if (additionalFields)
|
||||||
obs_data_apply(response, additionalFields);
|
obs_data_apply(response, additionalFields);
|
||||||
|
|
||||||
_client->sendTextMessage(obs_data_get_json(response));
|
SendResponse(response);
|
||||||
|
|
||||||
obs_data_release(response);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WSRequestHandler::SendErrorResponse(const char* errorMessage)
|
void WSRequestHandler::SendErrorResponse(const char* errorMessage)
|
||||||
@ -173,9 +171,20 @@ void WSRequestHandler::SendErrorResponse(const char* errorMessage)
|
|||||||
obs_data_set_string(response, "error", errorMessage);
|
obs_data_set_string(response, "error", errorMessage);
|
||||||
obs_data_set_string(response, "message-id", _messageId);
|
obs_data_set_string(response, "message-id", _messageId);
|
||||||
|
|
||||||
_client->sendTextMessage(obs_data_get_json(response));
|
SendResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WSRequestHandler::SendResponse(obs_data_t* response)
|
||||||
|
{
|
||||||
|
const char *json = obs_data_get_json(response);
|
||||||
obs_data_release(response);
|
obs_data_release(response);
|
||||||
|
|
||||||
|
if (Config::Current()->DebugEnabled)
|
||||||
|
{
|
||||||
|
blog(LOG_DEBUG, "Response << '%s'", json);
|
||||||
|
}
|
||||||
|
|
||||||
|
_client->sendTextMessage(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WSRequestHandler::hasField(const char* name)
|
bool WSRequestHandler::hasField(const char* name)
|
||||||
|
@ -45,6 +45,7 @@ class WSRequestHandler : public QObject
|
|||||||
|
|
||||||
void SendOKResponse(obs_data_t* additionalFields = NULL);
|
void SendOKResponse(obs_data_t* additionalFields = NULL);
|
||||||
void SendErrorResponse(const char* errorMessage);
|
void SendErrorResponse(const char* errorMessage);
|
||||||
|
void SendResponse(obs_data_t* response);
|
||||||
|
|
||||||
static void HandleGetVersion(WSRequestHandler* req);
|
static void HandleGetVersion(WSRequestHandler* req);
|
||||||
static void HandleGetAuthRequired(WSRequestHandler* req);
|
static void HandleGetAuthRequired(WSRequestHandler* req);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user