2020-06-13 09:28:08 +00:00
|
|
|
/**
|
|
|
|
* WebSocket client
|
|
|
|
*
|
|
|
|
* @author Pierre Hubert
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "apiresponse.h"
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QWebSocket>
|
|
|
|
|
|
|
|
class WsClient : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit WsClient(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void startConnect();
|
|
|
|
|
|
|
|
signals:
|
2020-06-13 11:57:29 +00:00
|
|
|
void newNumberNotifs(int num);
|
|
|
|
void newNumberConvs(int num);
|
2020-06-13 09:28:08 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void onConnectionError();
|
|
|
|
void getTokenCallBack(APIResponse res);
|
|
|
|
void onConnected();
|
2020-06-13 09:45:08 +00:00
|
|
|
void onMessage(const QString &msg);
|
2020-06-13 09:28:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Class members
|
|
|
|
QWebSocket mWebSocket;
|
|
|
|
};
|
|
|
|
|