diff options
author | Naveen Bobbili <nbobbili@amazon.com> | 2019-04-28 20:51:16 -0700 |
---|---|---|
committer | Jan-Simon Möller <jsmoeller@linuxfoundation.org> | 2019-06-24 14:14:42 +0200 |
commit | 9f02e451dd2f91c217d73c8029bb939b3a211672 (patch) | |
tree | d79eb0f93e835746169b3a96454cf8da70c0c037 /homescreen/src/aglsocketwrapper.h | |
parent | 2509e623a5f95a612a715818f15daddf2ca77f12 (diff) |
Code commit by ICS team to add Alexa Voice Chrome to Homescreen App.sandbox/jsmoeller/speechdemo
Change-Id: I2052e345baaf4306e8e3f27a01bc6940f4d27d88
Signed-off-by: Naveen Bobbili <nbobbili@amazon.com>
Diffstat (limited to 'homescreen/src/aglsocketwrapper.h')
-rwxr-xr-x | homescreen/src/aglsocketwrapper.h | 35 |
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 |