-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebsocker_worker.h
45 lines (37 loc) · 999 Bytes
/
websocker_worker.h
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
36
37
38
39
40
41
42
43
44
45
#pragma once
#include <QObject>
#include <QWebSocket>
#include <QThread>
#include <QJsonArray>
#include <QJsonObject>
#include <QJsonDocument>
#include <QMessageAuthenticationCode>
class WebSocker_Worker : public QObject
{
Q_OBJECT
public:
explicit WebSocker_Worker(const QString &apiKey, const QString &secretKey, QObject *parent = nullptr);
~WebSocker_Worker();
void connectToStream();
void disconnect();
public slots:
void start();
void stop();
signals:
void connected();
void disconnected();
void messageReceived(const QString &message);
void error(const QString &errorString);
private slots:
void onConnected();
void onDisconnected();
void onTextMessageReceived(const QString& message);
void onError(QAbstractSocket::SocketError error);
private:
QString m_apiKey;
QString m_secretKey;
QWebSocket *m_webSocket;
bool m_isRunning;
void setupWebSocker();
QString generateSignature(const QString& data);
};