mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
Merge pull request #298 from Palakis/bugfix/264-debug-logging
fix debug logging
This commit is contained in:
commit
b8af848d3a
@ -224,8 +224,9 @@ void WSEvents::broadcastUpdate(const char* updateType,
|
||||
QString json = obs_data_get_json(update);
|
||||
_srv->broadcast(json.toStdString());
|
||||
|
||||
if (Config::Current()->DebugEnabled)
|
||||
blog(LOG_DEBUG, "Update << '%s'", json.toUtf8().constData());
|
||||
if (Config::Current()->DebugEnabled) {
|
||||
blog(LOG_INFO, "Update << '%s'", json.toUtf8().constData());
|
||||
}
|
||||
}
|
||||
|
||||
void WSEvents::hookTransitionBeginEvent() {
|
||||
|
@ -139,7 +139,22 @@ WSRequestHandler::WSRequestHandler(QVariantHash& connProperties) :
|
||||
{
|
||||
}
|
||||
|
||||
obs_data_t* WSRequestHandler::processIncomingMessage(std::string& textMessage) {
|
||||
std::string WSRequestHandler::processIncomingMessage(std::string& textMessage) {
|
||||
if (Config::Current()->DebugEnabled) {
|
||||
blog(LOG_INFO, "Request >> '%s'", textMessage.c_str());
|
||||
}
|
||||
|
||||
OBSDataAutoRelease responseData = processRequest(textMessage);
|
||||
std::string response = obs_data_get_json(responseData);
|
||||
|
||||
if (Config::Current()->DebugEnabled) {
|
||||
blog(LOG_INFO, "Response << '%s'", response.c_str());
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
HandlerResponse WSRequestHandler::processRequest(std::string& textMessage){
|
||||
std::string msgContainer(textMessage);
|
||||
const char* msg = msgContainer.c_str();
|
||||
|
||||
@ -149,10 +164,6 @@ obs_data_t* WSRequestHandler::processIncomingMessage(std::string& textMessage) {
|
||||
return SendErrorResponse("invalid JSON payload");
|
||||
}
|
||||
|
||||
if (Config::Current()->DebugEnabled) {
|
||||
blog(LOG_DEBUG, "Request >> '%s'", msg);
|
||||
}
|
||||
|
||||
if (!hasField("request-type") || !hasField("message-id")) {
|
||||
return SendErrorResponse("missing request parameters");
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ class WSRequestHandler : public QObject {
|
||||
public:
|
||||
explicit WSRequestHandler(QVariantHash& connProperties);
|
||||
~WSRequestHandler();
|
||||
obs_data_t* processIncomingMessage(std::string& textMessage);
|
||||
std::string processIncomingMessage(std::string& textMessage);
|
||||
bool hasField(QString name);
|
||||
|
||||
private:
|
||||
@ -45,6 +45,8 @@ class WSRequestHandler : public QObject {
|
||||
QVariantHash& _connProperties;
|
||||
OBSDataAutoRelease data;
|
||||
|
||||
HandlerResponse processRequest(std::string& textMessage);
|
||||
|
||||
HandlerResponse SendOKResponse(obs_data_t* additionalFields = nullptr);
|
||||
HandlerResponse SendErrorResponse(const char* errorMessage);
|
||||
HandlerResponse SendErrorResponse(obs_data_t* additionalFields = nullptr);
|
||||
|
@ -139,13 +139,7 @@ void WSServer::onMessage(connection_hdl hdl, server::message_ptr message)
|
||||
locker.unlock();
|
||||
|
||||
WSRequestHandler handler(connProperties);
|
||||
OBSDataAutoRelease responseData = handler.processIncomingMessage(payload);
|
||||
|
||||
std::string response = obs_data_get_json(responseData);
|
||||
|
||||
if (Config::Current()->DebugEnabled) {
|
||||
blog(LOG_DEBUG, "Response << '%s'", response.c_str());
|
||||
}
|
||||
std::string response = handler.processIncomingMessage(payload);
|
||||
|
||||
_server.send(hdl, response, websocketpp::frame::opcode::text);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user