diff --git a/Config.cpp b/Config.cpp
index 515593c4..8fbb65a0 100644
--- a/Config.cpp
+++ b/Config.cpp
@@ -20,6 +20,7 @@ with this program. If not, see
#include
#include
#include
+
#include "Config.h"
#define SECTION_NAME "WebsocketAPI"
diff --git a/Config.h b/Config.h
index a39b1796..4a88b9f2 100644
--- a/Config.h
+++ b/Config.h
@@ -19,7 +19,6 @@ with this program. If not, see
#ifndef CONFIG_H
#define CONFIG_H
-#include
#include
#include
diff --git a/Utils.cpp b/Utils.cpp
index dee2268d..a35a7502 100644
--- a/Utils.cpp
+++ b/Utils.cpp
@@ -17,6 +17,7 @@ with this program. If not, see
*/
#include "Utils.h"
+#include
obs_data_array_t* Utils::GetSceneItems(obs_source_t *source) {
obs_data_array_t *items = obs_data_array_create();
diff --git a/Utils.h b/Utils.h
index f445d34b..7fbcd963 100644
--- a/Utils.h
+++ b/Utils.h
@@ -21,7 +21,6 @@ with this program. If not, see
#include
#include
-#include
class Utils
{
diff --git a/WSEvents.cpp b/WSEvents.cpp
index 09714f32..0bce95e1 100644
--- a/WSEvents.cpp
+++ b/WSEvents.cpp
@@ -17,6 +17,9 @@ You should have received a copy of the GNU General Public License along
with this program. If not, see
*/
+#include
+#include
+
#include "WSEvents.h"
WSEvents::WSEvents(WSServer *srv) {
diff --git a/WSEvents.h b/WSEvents.h
index 6bcbbd67..d3e210b7 100644
--- a/WSEvents.h
+++ b/WSEvents.h
@@ -20,10 +20,8 @@ with this program. If not, see
#ifndef WSEVENTS_H
#define WSEVENTS_H
-#include
-#include
#include
-#include
+
#include "WSServer.h"
class WSEvents : public QObject
diff --git a/WSRequestHandler.cpp b/WSRequestHandler.cpp
index bfea1afb..36b0da22 100644
--- a/WSRequestHandler.cpp
+++ b/WSRequestHandler.cpp
@@ -73,7 +73,7 @@ void WSRequestHandler::processIncomingMessage(QString textMessage)
msg = "";
}
- blog(LOG_ERROR, "[obs-websockets] invalid JSON payload received for '%s'", msg);
+ blog(LOG_ERROR, "invalid JSON payload received for '%s'", msg);
SendErrorResponse("invalid JSON payload");
return;
}
@@ -181,18 +181,13 @@ void WSRequestHandler::HandleAuthenticate(WSRequestHandler *owner)
return;
}
- blog(LOG_INFO, "[obs-websocket] preauth : client_authenticated : %d", owner->_client->property(PROP_AUTHENTICATED).toBool());
-
if ((owner->_client->property(PROP_AUTHENTICATED).toBool() == false) && Config::Current()->CheckAuth(auth))
{
- blog(LOG_INFO, "[obs-websocket] auth successful");
-
owner->_client->setProperty(PROP_AUTHENTICATED, true);
owner->SendOKResponse();
}
else
{
- blog(LOG_INFO, "[obs-websocket] auth refused");
owner->SendErrorResponse("Authentication Failed.");
}
}
diff --git a/WSRequestHandler.h b/WSRequestHandler.h
index 4cb621e4..91251da4 100644
--- a/WSRequestHandler.h
+++ b/WSRequestHandler.h
@@ -20,9 +20,9 @@ with this program. If not, see
#ifndef WSREQUESTHANDLER_H
#define WSREQUESTHANDLER_H
+#include
#include
#include
-#include
class WSRequestHandler : public QObject
{
diff --git a/WSServer.cpp b/WSServer.cpp
index 6de8ffa9..ffdeea97 100644
--- a/WSServer.cpp
+++ b/WSServer.cpp
@@ -16,20 +16,18 @@ You should have received a copy of the GNU General Public License along
with this program. If not, see
*/
-#include "WSServer.h"
-#include "WSRequestHandler.h"
-#include "Config.h"
-#include
#include
-#include
#include
+#include
#include
+#include "WSServer.h"
#include "obs-websocket.h"
+#include "Config.h"
QT_USE_NAMESPACE
-WSServer* WSServer::Instance = new WSServer();
+WSServer* WSServer::Instance = nullptr;
WSServer::WSServer(QObject *parent) :
QObject(parent),
@@ -116,7 +114,7 @@ void WSServer::onNewConnection()
_clMutex.unlock();
QByteArray client_ip = pSocket->peerAddress().toString().toUtf8();
- blog(LOG_INFO, "[obs-websockets] new client connection from %s:%d", client_ip.constData(), pSocket->peerPort());
+ blog(LOG_INFO, "new client connection from %s:%d", client_ip.constData(), pSocket->peerPort());
}
}
@@ -146,6 +144,6 @@ void WSServer::socketDisconnected()
pSocket->deleteLater();
QByteArray client_ip = pSocket->peerAddress().toString().toUtf8();
- blog(LOG_INFO, "[obs-websockets] client %s:%d disconnected", client_ip.constData(), pSocket->peerPort());
+ blog(LOG_INFO, "client %s:%d disconnected", client_ip.constData(), pSocket->peerPort());
}
}
\ No newline at end of file
diff --git a/WSServer.h b/WSServer.h
index 10b9971e..3d48f2a9 100644
--- a/WSServer.h
+++ b/WSServer.h
@@ -22,13 +22,12 @@ with this program. If not, see
#include
#include
#include
-#include
-#include
-#include "WSRequestHandler.h"
QT_FORWARD_DECLARE_CLASS(QWebSocketServer)
QT_FORWARD_DECLARE_CLASS(QWebSocket)
+#include "WSRequestHandler.h"
+
class WSServer : public QObject
{
Q_OBJECT
diff --git a/obs-websocket.cpp b/obs-websocket.cpp
index 01c0644f..4b38ee2c 100644
--- a/obs-websocket.cpp
+++ b/obs-websocket.cpp
@@ -19,6 +19,7 @@ with this program. If not, see
#include
#include
#include
+#include
#include "obs-websocket.h"
#include "WSServer.h"
@@ -34,10 +35,14 @@ SettingsDialog *settings_dialog;
bool obs_module_load(void)
{
+ blog(LOG_INFO, "you can haz websockets (version %s)", OBS_WEBSOCKET_VERSION);
+
// Core setup
Config* config = Config::Current();
config->Load();
+ WSServer::Instance = new WSServer();
+
if (config->ServerEnabled)
WSServer::Instance->Start(config->ServerPort);
@@ -47,7 +52,8 @@ bool obs_module_load(void)
QAction *menu_action = (QAction*)obs_frontend_add_tools_menu_qaction(obs_module_text("OBSWebsocket.Menu.SettingsItem"));
obs_frontend_push_ui_translation(obs_module_get_string);
- settings_dialog = new SettingsDialog();
+ QMainWindow* main_window = (QMainWindow*)obs_frontend_get_main_window();
+ settings_dialog = new SettingsDialog(main_window);
obs_frontend_pop_ui_translation();
auto menu_cb = [] {
@@ -56,13 +62,13 @@ bool obs_module_load(void)
menu_action->connect(menu_action, &QAction::triggered, menu_cb);
// Loading finished
- blog(LOG_INFO, "[obs-websockets] you can haz websockets (version %s)", OBS_WEBSOCKET_VERSION);
+ blog(LOG_INFO, "module loaded!");
return true;
}
void obs_module_unload()
{
- blog(LOG_INFO, "[obs-websockets] goodbye !");
+ blog(LOG_INFO, "goodbye!");
}
diff --git a/obs-websocket.h b/obs-websocket.h
index 2001ec5c..fd485110 100644
--- a/obs-websocket.h
+++ b/obs-websocket.h
@@ -22,4 +22,6 @@ with this program. If not, see
#define PROP_AUTHENTICATED "wsclient_authenticated"
#define OBS_WEBSOCKET_VERSION "4.0.0"
+#define blog(level, msg, ...) blog(level, "[obs-websocket] " msg, ##__VA_ARGS__)
+
#endif // OBSWEBSOCKET_H
\ No newline at end of file