diff options
author | Loïc Collignon <loic.collignon@iot.bzh> | 2018-02-23 13:57:35 +0100 |
---|---|---|
committer | Loïc Collignon <loic.collignon@iot.bzh> | 2018-02-23 13:57:35 +0100 |
commit | d2f071d5d8c5c21c4f438bf5a822fbaddb2d97ce (patch) | |
tree | e69b8367c41b2a23c107d86c2467977d7cb39d57 /homescreen/src/qafbwsclient.h | |
parent | 43dc156f29b89efd4055b8b412e888c0c3129e7b (diff) |
hack: control master volume using 4a with the homescreen slidersandbox/ctxnop/4avolume
Change-Id: If527d160f8eacbcfed3df2ab744485995dbe1dc9
Signed-off-by: Loïc Collignon <loic.collignon@iot.bzh>
Diffstat (limited to 'homescreen/src/qafbwsclient.h')
-rw-r--r-- | homescreen/src/qafbwsclient.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/homescreen/src/qafbwsclient.h b/homescreen/src/qafbwsclient.h new file mode 100644 index 0000000..2576ecb --- /dev/null +++ b/homescreen/src/qafbwsclient.h @@ -0,0 +1,50 @@ +#ifndef QAFBWSCLIENT_H +#define QAFBWSCLIENT_H + +#include <QObject> +#include <QMap> +#include <QSharedPointer> +#include <QWebSocket> +#include <QJsonValue> + +enum class AfMsgType + : int +{ + Call = 2, + RetOk = 3, + RetErr = 4, + Event = 5 +}; + +class QAfbWsMsg; + +class QAfbWsClient + : public QObject +{ + Q_OBJECT +public: + explicit QAfbWsClient(QObject* parent = nullptr); + + void open(const QUrl& url); + void close(); + QUrl url() const; + QSharedPointer<QAfbWsMsg> call(const QString &api, const QString &verb, const QJsonValue &args = QJsonValue()); + +signals: + void connected(); + void disconnected(); + void error(QAbstractSocket::SocketError err, QString errStr); + +private slots: + void onSocketConnected(); + void onSocketDisconnected(); + void onSocketError(QAbstractSocket::SocketError err); + void onSocketTextMessageReceived(QString msg); + +private: + int m_nextCallId; + QWebSocket m_socket; + QMap<int, QSharedPointer<QAfbWsMsg>> m_calls; +}; + +#endif // QAFBWSCLIENT_H |