aboutsummaryrefslogtreecommitdiffstats
path: root/homescreen/src/aglsocketwrapper.h
diff options
context:
space:
mode:
Diffstat (limited to 'homescreen/src/aglsocketwrapper.h')
-rwxr-xr-xhomescreen/src/aglsocketwrapper.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/homescreen/src/aglsocketwrapper.h b/homescreen/src/aglsocketwrapper.h
new file mode 100755
index 0000000..4807cd5
--- /dev/null
+++ b/homescreen/src/aglsocketwrapper.h
@@ -0,0 +1,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