-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathObsWebSocket.hpp
37 lines (31 loc) · 951 Bytes
/
ObsWebSocket.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef OBSWEBSOCKET_H
#define OBSWEBSOCKET_H
#include <QJsonObject>
#include <QtCore/QObject>
#include <QtWebSockets/QWebSocket>
class ObsWebSocket : public QObject
{
Q_OBJECT
public:
explicit ObsWebSocket(const QUrl &url, bool debug = false, QObject *parent = nullptr);
void setAddress(const QUrl &url);
void sendRequest(const QString &requestType, int msgId);
void sendRequest(const QString &requestType, int msgId, const QJsonObject &data);
QString jsonToString(const QJsonObject &json);
QJsonObject stringToJson(const QString &in);
bool isConnected();
signals:
void onResponse(QJsonObject json);
void connected(bool isConnected);
private slots:
void onConnected();
void onClosed();
void onMessageReceived(const QString &message);
void startWebsocket();
private:
QWebSocket m_webSocket;
QUrl m_url;
bool m_debug;
bool m_isConnected = false;
};
#endif // OBSWEBSOCKET_H