summaryrefslogtreecommitdiffstats
path: root/app/qafbwsclient.h
diff options
context:
space:
mode:
authorLoïc Collignon <loic.collignon@iot.bzh>2018-03-13 08:56:37 +0100
committerLoïc Collignon <loic.collignon@iot.bzh>2018-06-14 11:36:47 +0200
commit6bf2ccbd72176a8cbdfb3cdb2c15ee1c2db594b8 (patch)
tree52d9432e8f74507e4aaf477ca5605de6812bdecf /app/qafbwsclient.h
parent47695d79a938eb52c116062c218147049b994246 (diff)
make use of alsacore and hal bindings to control audio volume
Change-Id: Ib7e90a7d2a148a067566bc04929fda445b46ab45 Signed-off-by: Loïc Collignon <loic.collignon@iot.bzh>
Diffstat (limited to 'app/qafbwsclient.h')
-rw-r--r--app/qafbwsclient.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/app/qafbwsclient.h b/app/qafbwsclient.h
new file mode 100644
index 0000000..2576ecb
--- /dev/null
+++ b/app/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