forked from 2600hz/kazoo-popup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
websocketmanager.h
69 lines (53 loc) · 1.74 KB
/
websocketmanager.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef WEBSOCKETMANAGER_H
#define WEBSOCKETMANAGER_H
#include <QObject>
#include <QHash>
#include <QStringList>
class QNetworkAccessManager;
class QWebSocket;
class QSettings;
class QTimer;
class Caller;
class WebSocketManager : public QObject
{
Q_OBJECT
public:
explicit WebSocketManager(QObject *parent = 0);
~WebSocketManager();
public slots:
void start();
void stop();
private:
void retrieveAuthToken();
void processWsData(const QString &data);
void processChannelCreate(const QJsonObject &args);
void processChannelAnswer(const QJsonObject &args);
void processChannelDestroy(const QJsonObject &args);
bool isSupportCallDirection(const QString &callDirection);
QNetworkAccessManager *m_nam = nullptr;
QWebSocket *m_webSocket = nullptr;
QTimer *m_timer = nullptr;
QSettings *m_settings = nullptr;
qint64 m_lastPing = 0;
QString m_authToken;
QString m_accountId;
QStringList m_devices;
QHash<QString, Caller> m_callersHash;
signals:
void channelCreated(const QString &callId, const Caller &caller);
void channelAnswered(const QString &callId);
void channelAnsweredAnother(const QString &callId, const QString &calleeNumber, const QString &calleeName);
void channelDestroyed(const QString &callId);
void connectionError();
void connected();
private slots:
void retrieveAuthTokenFinished();
void retrieveDevicesFinished();
void retrieveWsAddressFinished();
void webSocketConnected();
void webSocketDisconnected();
void webSocketTextFrameReceived(const QString &frame);
void checkPingTimeout();
void handleConnectionError();
};
#endif // WEBSOCKETMANAGER_H