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)
|
||||
project(obs-websocket VERSION 5.0.0)
|
||||
set(OBS_WEBSOCKET_RPC_VERSION 1)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
@ -72,6 +73,7 @@ set(obs-websocket_SOURCES
|
||||
src/obs-websocket.cpp
|
||||
src/Config.cpp
|
||||
src/WebSocketServer.cpp
|
||||
src/WebSocketSession.cpp
|
||||
src/requesthandler/RequestHandler.cpp
|
||||
src/requesthandler/rpc/Request.cpp
|
||||
src/requesthandler/rpc/RequestResult.cpp
|
||||
@ -82,6 +84,7 @@ set(obs-websocket_HEADERS
|
||||
src/obs-websocket.h
|
||||
src/Config.h
|
||||
src/WebSocketServer.h
|
||||
src/WebSocketSession.h
|
||||
src/requesthandler/RequestHandler.h
|
||||
src/requesthandler/rpc/Request.h
|
||||
src/requesthandler/rpc/RequestResult.h
|
||||
|
@ -1 +1,4 @@
|
||||
#include <QtConcurrent>
|
||||
|
||||
#include "WebSocketServer.h"
|
||||
#include "requesthandler/RequestHandler.h"
|
@ -1,17 +1,57 @@
|
||||
#pragma once
|
||||
|
||||
#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"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
class WebSocketServer : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
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:
|
||||
;
|
||||
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;
|
||||
};
|
@ -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_RPC_VERSION 1
|
||||
|
||||
#define QT_TO_UTF8(str) str.toUtf8().constData()
|
||||
|
||||
#define blog(level, msg, ...) blog(level, "[obs-websocket] " msg, ##__VA_ARGS__)
|
||||
|
@ -21,6 +21,8 @@ with this program. If not, see <https://www.gnu.org/licenses/>
|
||||
|
||||
#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 blog(level, msg, ...) blog(level, "[obs-websocket] " msg, ##__VA_ARGS__)
|
||||
|
Loading…
Reference in New Issue
Block a user