mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
Base: Tons more shit
This commit is contained in:
parent
fb22b31612
commit
8067cfb686
@ -1,5 +1,6 @@
|
|||||||
cmake_minimum_required(VERSION 3.16...3.20)
|
cmake_minimum_required(VERSION 3.16...3.20)
|
||||||
project(obs-websocket VERSION 5.0.0)
|
project(obs-websocket VERSION 5.0.0)
|
||||||
|
set(OBS_WEBSOCKET_RPC_VERSION 1)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
@ -72,6 +73,7 @@ set(obs-websocket_SOURCES
|
|||||||
src/obs-websocket.cpp
|
src/obs-websocket.cpp
|
||||||
src/Config.cpp
|
src/Config.cpp
|
||||||
src/WebSocketServer.cpp
|
src/WebSocketServer.cpp
|
||||||
|
src/WebSocketSession.cpp
|
||||||
src/requesthandler/RequestHandler.cpp
|
src/requesthandler/RequestHandler.cpp
|
||||||
src/requesthandler/rpc/Request.cpp
|
src/requesthandler/rpc/Request.cpp
|
||||||
src/requesthandler/rpc/RequestResult.cpp
|
src/requesthandler/rpc/RequestResult.cpp
|
||||||
@ -82,6 +84,7 @@ set(obs-websocket_HEADERS
|
|||||||
src/obs-websocket.h
|
src/obs-websocket.h
|
||||||
src/Config.h
|
src/Config.h
|
||||||
src/WebSocketServer.h
|
src/WebSocketServer.h
|
||||||
|
src/WebSocketSession.h
|
||||||
src/requesthandler/RequestHandler.h
|
src/requesthandler/RequestHandler.h
|
||||||
src/requesthandler/rpc/Request.h
|
src/requesthandler/rpc/Request.h
|
||||||
src/requesthandler/rpc/RequestResult.h
|
src/requesthandler/rpc/RequestResult.h
|
||||||
|
@ -20,4 +20,4 @@ OBSWebSocket.NotifyDisconnect.Title="WebSocket client disconnected."
|
|||||||
OBSWebSocket.NotifyDisconnect.Message="Client %1 disconnected"
|
OBSWebSocket.NotifyDisconnect.Message="Client %1 disconnected"
|
||||||
|
|
||||||
OBSWebSocket.Server.StartFailed.Title="WebSocket Server Failure"
|
OBSWebSocket.Server.StartFailed.Title="WebSocket Server Failure"
|
||||||
OBSWebSocket.Server.StartFailed.Message="The WebSocket server failed to start. TCP port %1 may already be in use elsewhere on this system by another application. Try setting a different TCP port in the WebSocket server settings, or stop any application that could be using this port.\n Error message: %2"
|
OBSWebSocket.Server.StartFailed.Message="The WebSocket server failed to start. TCP port %1 may already be in use elsewhere on this system by another application. Try setting a different TCP port in the WebSocket server settings, or stop any application that could be using this port.\n Error message: %2"
|
||||||
|
@ -78,4 +78,4 @@ void Config::SetDefaultsToGlobalStore()
|
|||||||
config_t* Config::GetConfigStore()
|
config_t* Config::GetConfigStore()
|
||||||
{
|
{
|
||||||
return obs_frontend_get_global_config();
|
return obs_frontend_get_global_config();
|
||||||
}
|
}
|
||||||
|
@ -22,4 +22,4 @@ class Config {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
;
|
;
|
||||||
};
|
};
|
||||||
|
@ -1 +1,4 @@
|
|||||||
#include "WebSocketServer.h"
|
#include <QtConcurrent>
|
||||||
|
|
||||||
|
#include "WebSocketServer.h"
|
||||||
|
#include "requesthandler/RequestHandler.h"
|
@ -1,17 +1,57 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <nlohmann/json.hpp>
|
#include <QThreadPool>
|
||||||
|
#include <QMutex>
|
||||||
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
#include <websocketpp/config/asio_no_tls.hpp>
|
||||||
|
#include <websocketpp/server.hpp>
|
||||||
|
|
||||||
|
#include "WebSocketSession.h"
|
||||||
#include "requesthandler/RequestHandler.h"
|
#include "requesthandler/RequestHandler.h"
|
||||||
|
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
class WebSocketServer : public QObject
|
class WebSocketServer : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
;
|
WebSocketServer();
|
||||||
|
~WebSocketServer();
|
||||||
|
|
||||||
|
void Start();
|
||||||
|
void Stop();
|
||||||
|
void InvalidateSession(websocketpp::connection_hdl hdl);
|
||||||
|
|
||||||
|
struct WebSocketState {
|
||||||
|
websocketpp::connection_hdl hdl;
|
||||||
|
std::string remoteAddress;
|
||||||
|
uint64_t durationSeconds;
|
||||||
|
uint64_t incomingMessages;
|
||||||
|
uint64_t outgoingMessages;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<WebSocketState> GetWebSocketSessions();
|
||||||
|
|
||||||
|
QThreadPool *GetThreadPool() {
|
||||||
|
return &_threadPool;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
void BroadcastEvent(uint64_t requiredIntent, std::string eventType, json eventData = nullptr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
;
|
void onOpen(websocketpp::connection_hdl hdl);
|
||||||
};
|
void onClose(websocketpp::connection_hdl hdl);
|
||||||
|
void onMessage(websocketpp::connection_hdl hdl);
|
||||||
|
|
||||||
|
WebSocketSession *GetWebSocketSession(websocketpp::connection_hdl hdl);
|
||||||
|
|
||||||
|
websocketpp::server<websocketpp::config::asio> _server;
|
||||||
|
QThreadPool _threadPool;
|
||||||
|
|
||||||
|
QMutex _sessionMutex;
|
||||||
|
std::map<websocketpp::connection_hdl, WebSocketSession, std::owner_less<websocketpp::connection_hdl>> _sessions;
|
||||||
|
};
|
||||||
|
@ -115,4 +115,4 @@ void SettingsDialog::CopyPasswordButtonClicked()
|
|||||||
QClipboard *clipboard = QGuiApplication::clipboard();
|
QClipboard *clipboard = QGuiApplication::clipboard();
|
||||||
clipboard->setText(ui->serverPasswordLineEdit->text());
|
clipboard->setText(ui->serverPasswordLineEdit->text());
|
||||||
ui->serverPasswordLineEdit->selectAll();
|
ui->serverPasswordLineEdit->selectAll();
|
||||||
}
|
}
|
||||||
|
@ -23,4 +23,4 @@ private:
|
|||||||
Ui::SettingsDialog* ui;
|
Ui::SettingsDialog* ui;
|
||||||
|
|
||||||
void FillSessionTable();
|
void FillSessionTable();
|
||||||
};
|
};
|
||||||
|
@ -72,4 +72,4 @@ ConfigPtr GetConfig()
|
|||||||
WebSocketServerPtr GetWebSocketServer()
|
WebSocketServerPtr GetWebSocketServer()
|
||||||
{
|
{
|
||||||
return _webSocketServer;
|
return _webSocketServer;
|
||||||
}
|
}
|
||||||
|
@ -36,4 +36,4 @@ typedef std::shared_ptr<WebSocketServer> WebSocketServerPtr;
|
|||||||
|
|
||||||
ConfigPtr GetConfig();
|
ConfigPtr GetConfig();
|
||||||
|
|
||||||
WebSocketServerPtr GetWebSocketServer();
|
WebSocketServerPtr GetWebSocketServer();
|
||||||
|
@ -21,6 +21,8 @@ with this program. If not, see <https://www.gnu.org/licenses/>
|
|||||||
|
|
||||||
#define OBS_WEBSOCKET_VERSION "5.0.0"
|
#define OBS_WEBSOCKET_VERSION "5.0.0"
|
||||||
|
|
||||||
|
#define OBS_WEBSOCKET_RPC_VERSION 1
|
||||||
|
|
||||||
#define QT_TO_UTF8(str) str.toUtf8().constData()
|
#define QT_TO_UTF8(str) str.toUtf8().constData()
|
||||||
|
|
||||||
#define blog(level, msg, ...) blog(level, "[obs-websocket] " msg, ##__VA_ARGS__)
|
#define blog(level, msg, ...) blog(level, "[obs-websocket] " msg, ##__VA_ARGS__)
|
||||||
|
@ -21,8 +21,10 @@ with this program. If not, see <https://www.gnu.org/licenses/>
|
|||||||
|
|
||||||
#define OBS_WEBSOCKET_VERSION "@CMAKE_PROJECT_VERSION@"
|
#define OBS_WEBSOCKET_VERSION "@CMAKE_PROJECT_VERSION@"
|
||||||
|
|
||||||
|
#define OBS_WEBSOCKET_RPC_VERSION @OBS_WEBSOCKET_RPC_VERSION@
|
||||||
|
|
||||||
#define QT_TO_UTF8(str) str.toUtf8().constData()
|
#define QT_TO_UTF8(str) str.toUtf8().constData()
|
||||||
|
|
||||||
#define blog(level, msg, ...) blog(level, "[obs-websocket] " msg, ##__VA_ARGS__)
|
#define blog(level, msg, ...) blog(level, "[obs-websocket] " msg, ##__VA_ARGS__)
|
||||||
|
|
||||||
#endif // PLUGINNAME_H
|
#endif // PLUGINNAME_H
|
||||||
|
@ -1 +1 @@
|
|||||||
#include "RequestHandler.h"
|
#include "RequestHandler.h"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "rpc/Request.h"
|
#include "rpc/Request.h"
|
||||||
#include "rpc/RequestResult.h"
|
#include "rpc/RequestResult.h"
|
||||||
|
@ -1 +1 @@
|
|||||||
#include "Request.h"
|
#include "Request.h"
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
@ -1 +1 @@
|
|||||||
#include "RequestResult.h"
|
#include "RequestResult.h"
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
@ -145,4 +145,4 @@ json JsonUtils::ObsDataToJson(obs_data_t *d, bool includeDefault)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
@ -12,4 +12,4 @@ namespace JsonUtils {
|
|||||||
bool JsonArrayIsValidObsArray(json j);
|
bool JsonArrayIsValidObsArray(json j);
|
||||||
obs_data_t *JsonToObsData(json j);
|
obs_data_t *JsonToObsData(json j);
|
||||||
json ObsDataToJson(obs_data_t *d, bool includeDefault = false);
|
json ObsDataToJson(obs_data_t *d, bool includeDefault = false);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user