blob: 4807cd5b4c180f9de63edc8469c2047f620c6f11 (
plain)
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
|
#ifndef AGLSOCKETWRAPPER_H
#define AGLSOCKETWRAPPER_H
#include <QUrl>
#include <QMap>
#include <QObject>
#include <QJsonValue>
#include <functional>
class QWebSocket;
class AglSocketWrapper : public QObject
{
Q_OBJECT
public:
explicit AglSocketWrapper(QObject *parent = nullptr);
void open(const QUrl &url);
void close();
using ApiCallback = std::function<void(bool, const QJsonValue&)>;
void apiCall(const QString &api, const QString &verb, const QJsonValue &args = QJsonValue(),
ApiCallback callback = nullptr);
signals:
void connected();
void disconnected();
void eventReceived(const QString &eventName, const QJsonValue &data);
private:
QWebSocket *m_socket;
QMap<QString, ApiCallback> m_callbacks;
};
#endif // AGLSOCKETWRAPPER_H
|