mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
base: cmake is fucking retarded
This commit is contained in:
parent
5d170d6bb3
commit
d9ee288cf1
@ -89,7 +89,7 @@ set(obs-websocket_HEADERS
|
||||
src/requesthandler/rpc/Request.h
|
||||
src/requesthandler/rpc/RequestResult.h
|
||||
src/forms/SettingsDialog.h
|
||||
src/utils/JsonUtils.h)
|
||||
src/utils/Utils.h)
|
||||
|
||||
|
||||
# Platform-independent build settings
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include <QTime>
|
||||
#include <obs-frontend-api.h>
|
||||
|
||||
#include "plugin-macros.generated.h"
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#define CONFIG_SECTION_NAME "OBSWebSocket"
|
||||
|
@ -3,8 +3,6 @@
|
||||
#include <QString>
|
||||
#include <util/config-file.h>
|
||||
|
||||
#include "plugin-macros.generated.h"
|
||||
|
||||
class Config {
|
||||
public:
|
||||
Config();
|
||||
|
@ -1,4 +1,95 @@
|
||||
#include <QtConcurrent>
|
||||
|
||||
#include "plugin-macros.generated.h"
|
||||
|
||||
#include "WebSocketServer.h"
|
||||
#include "requesthandler/RequestHandler.h"
|
||||
#include "obs-websocket.h"
|
||||
#include "Config.h"
|
||||
#include "requesthandler/RequestHandler.h"
|
||||
|
||||
WebSocketServer::WebSocketServer() :
|
||||
QObject(nullptr),
|
||||
_sessionMutex(QMutex::Recursive),
|
||||
_sessions()
|
||||
{
|
||||
_server.get_alog().clear_channels(websocketpp::log::alevel::frame_header | websocketpp::log::alevel::frame_payload | websocketpp::log::alevel::control);
|
||||
_server.init_asio();
|
||||
|
||||
#ifndef _WIN32
|
||||
_server.set_reuse_addr(true);
|
||||
#endif
|
||||
|
||||
_server.set_open_handler(
|
||||
websocketpp::lib::bind(
|
||||
&WebSocketServer::onOpen, this, websocketpp::lib::placeholders::_1
|
||||
)
|
||||
);
|
||||
_server.set_close_handler(
|
||||
websocketpp::lib::bind(
|
||||
&WebSocketServer::onClose, this, websocketpp::lib::placeholders::_1
|
||||
)
|
||||
);
|
||||
_server.set_message_handler(
|
||||
websocketpp::lib::bind(
|
||||
&WebSocketServer::onMessage, this, websocketpp::lib::placeholders::_1, websocketpp::lib::placeholders::_2
|
||||
)
|
||||
);
|
||||
|
||||
blog(LOG_INFO, "test");
|
||||
}
|
||||
|
||||
WebSocketServer::~WebSocketServer()
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
|
||||
void WebSocketServer::Start()
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
void WebSocketServer::Stop()
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
void WebSocketServer::InvalidateSession(websocketpp::connection_hdl hdl)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
std::vector<WebSocketServer::WebSocketState> WebSocketServer::GetWebSocketSessions()
|
||||
{
|
||||
std::vector<WebSocketServer::WebSocketState> webSocketSessions;
|
||||
return webSocketSessions;
|
||||
}
|
||||
|
||||
std::string WebSocketServer::GetConnectUrl()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
void WebSocketServer::BroadcastEvent(uint64_t requiredIntent, std::string eventType, json eventData)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
WebSocketSession *WebSocketServer::GetWebSocketSession(websocketpp::connection_hdl hdl)
|
||||
{
|
||||
return new WebSocketSession();
|
||||
}
|
||||
|
||||
void WebSocketServer::onOpen(websocketpp::connection_hdl hdl)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
void WebSocketServer::onClose(websocketpp::connection_hdl hdl)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
void WebSocketServer::onMessage(websocketpp::connection_hdl hdl, websocketpp::server<websocketpp::config::asio>::message_ptr message)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include <websocketpp/server.hpp>
|
||||
|
||||
#include "WebSocketSession.h"
|
||||
#include "requesthandler/RequestHandler.h"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
@ -65,19 +64,21 @@ class WebSocketServer : public QObject
|
||||
return &_threadPool;
|
||||
}
|
||||
|
||||
std::string GetConnectUrl();
|
||||
|
||||
public Q_SLOTS:
|
||||
void BroadcastEvent(uint64_t requiredIntent, std::string eventType, json eventData = nullptr);
|
||||
|
||||
private:
|
||||
WebSocketSession *GetWebSocketSession(websocketpp::connection_hdl hdl);
|
||||
|
||||
void onOpen(websocketpp::connection_hdl hdl);
|
||||
void onClose(websocketpp::connection_hdl hdl);
|
||||
void onMessage(websocketpp::connection_hdl hdl);
|
||||
|
||||
WebSocketSession *GetWebSocketSession(websocketpp::connection_hdl hdl);
|
||||
void onMessage(websocketpp::connection_hdl hdl, websocketpp::server<websocketpp::config::asio>::message_ptr message);
|
||||
|
||||
websocketpp::server<websocketpp::config::asio> _server;
|
||||
QThreadPool _threadPool;
|
||||
|
||||
QMutex _sessionMutex;
|
||||
std::map<websocketpp::connection_hdl, WebSocketSession, std::owner_less<websocketpp::connection_hdl>> _sessions;
|
||||
uint16_t _serverPort;
|
||||
};
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include "plugin-macros.generated.h"
|
||||
|
||||
#include "WebSocketSession.h"
|
||||
|
||||
WebSocketSession::WebSocketSession() :
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#include "plugin-macros.generated.h"
|
||||
|
||||
class WebSocketSession
|
||||
{
|
||||
public:
|
||||
|
@ -4,6 +4,8 @@
|
||||
#include <QClipboard>
|
||||
#include <QTime>
|
||||
|
||||
#include "../plugin-macros.generated.h"
|
||||
|
||||
#include "SettingsDialog.h"
|
||||
#include "../obs-websocket.h"
|
||||
#include "../Config.h"
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include <QtWidgets/QAction>
|
||||
#include <QtWidgets/QMainWindow>
|
||||
|
||||
#include "plugin-macros.generated.h"
|
||||
|
||||
#include "obs-websocket.h"
|
||||
#include "Config.h"
|
||||
#include "WebSocketServer.h"
|
||||
|
@ -3,8 +3,6 @@
|
||||
#include <obs.hpp>
|
||||
#include <memory>
|
||||
|
||||
#include "plugin-macros.generated.h"
|
||||
|
||||
// Autorelease object declarations
|
||||
void ___source_dummy_addref(obs_source_t*);
|
||||
void ___sceneitem_dummy_addref(obs_sceneitem_t*);
|
||||
|
@ -27,4 +27,4 @@ with this program. If not, see <https://www.gnu.org/licenses/>
|
||||
|
||||
#define blog(level, msg, ...) blog(level, "[obs-websocket] " msg, ##__VA_ARGS__)
|
||||
|
||||
#endif // PLUGINNAME_H
|
||||
#endif
|
||||
|
@ -27,4 +27,4 @@ with this program. If not, see <https://www.gnu.org/licenses/>
|
||||
|
||||
#define blog(level, msg, ...) blog(level, "[obs-websocket] " msg, ##__VA_ARGS__)
|
||||
|
||||
#endif // PLUGINNAME_H
|
||||
#endif
|
||||
|
@ -1 +1,3 @@
|
||||
#include "../plugin-macros.generated.h"
|
||||
|
||||
#include "RequestHandler.h"
|
||||
|
@ -1 +1,3 @@
|
||||
#include "../../plugin-macros.generated.h"
|
||||
|
||||
#include "Request.h"
|
||||
|
@ -1 +1,3 @@
|
||||
#include "../../plugin-macros.generated.h"
|
||||
|
||||
#include "RequestResult.h"
|
||||
|
@ -1,6 +1,9 @@
|
||||
#include "JsonUtils.h"
|
||||
// For AutoRelease types
|
||||
#include "../obs-websocket.h"
|
||||
|
||||
bool JsonUtils::JsonArrayIsValidObsArray(json j)
|
||||
#include "Utils.h"
|
||||
|
||||
bool Utils::Json::JsonArrayIsValidObsArray(json j)
|
||||
{
|
||||
for (auto it : j) {
|
||||
if (!it.is_object())
|
||||
@ -54,7 +57,7 @@ void obs_data_set_json_object_item(obs_data_t *d, json j)
|
||||
}
|
||||
}
|
||||
|
||||
obs_data_t *JsonUtils::JsonToObsData(json j)
|
||||
obs_data_t *Utils::Json::JsonToObsData(json j)
|
||||
{
|
||||
obs_data_t *data = obs_data_create();
|
||||
|
||||
@ -93,7 +96,7 @@ void set_json_bool(json *j, const char *name, obs_data_item_t *item)
|
||||
void set_json_object(json *j, const char *name, obs_data_item_t *item, bool includeDefault)
|
||||
{
|
||||
obs_data_t *obj = obs_data_item_get_obj(item);
|
||||
j->emplace(name, JsonUtils::ObsDataToJson(obj, includeDefault));
|
||||
j->emplace(name, Utils::Json::ObsDataToJson(obj, includeDefault));
|
||||
obs_data_release(obj);
|
||||
}
|
||||
void set_json_array(json *j, const char *name, obs_data_item_t *item, bool includeDefault)
|
||||
@ -104,14 +107,14 @@ void set_json_array(json *j, const char *name, obs_data_item_t *item, bool inclu
|
||||
|
||||
for (size_t idx = 0; idx < count; idx++) {
|
||||
OBSDataAutoRelease subItem = obs_data_array_item(array, idx);
|
||||
json jItem = JsonUtils::ObsDataToJson(subItem, includeDefault);
|
||||
json jItem = Utils::Json::ObsDataToJson(subItem, includeDefault);
|
||||
jArray.push_back(jItem);
|
||||
}
|
||||
|
||||
j->emplace(name, jArray);
|
||||
}
|
||||
|
||||
json JsonUtils::ObsDataToJson(obs_data_t *d, bool includeDefault)
|
||||
json Utils::Json::ObsDataToJson(obs_data_t *d, bool includeDefault)
|
||||
{
|
||||
json j;
|
||||
obs_data_item_t *item = nullptr;
|
||||
|
@ -1,15 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <obs-data.h>
|
||||
|
||||
// For AutoRelease types
|
||||
#include "../obs-websocket.h"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
namespace JsonUtils {
|
||||
bool JsonArrayIsValidObsArray(json j);
|
||||
obs_data_t *JsonToObsData(json j);
|
||||
json ObsDataToJson(obs_data_t *d, bool includeDefault = false);
|
||||
};
|
14
src/utils/Utils.h
Normal file
14
src/utils/Utils.h
Normal file
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <obs-data.h>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
namespace Utils {
|
||||
namespace Json {
|
||||
bool JsonArrayIsValidObsArray(json j);
|
||||
obs_data_t *JsonToObsData(json j);
|
||||
json ObsDataToJson(obs_data_t *d, bool includeDefault = false);
|
||||
};
|
||||
};
|
Loading…
Reference in New Issue
Block a user