feather/src/utils/WebsocketClient.h

39 lines
859 B
C
Raw Normal View History

2021-05-02 18:22:38 +00:00
// SPDX-License-Identifier: BSD-3-Clause
2022-02-10 10:26:41 +00:00
// SPDX-FileCopyrightText: 2020-2022 The Monero Project
2021-05-02 18:22:38 +00:00
#ifndef FEATHER_WEBSOCKETCLIENT_H
#define FEATHER_WEBSOCKETCLIENT_H
#include <QObject>
#include <QWebSocket>
#include <QTimer>
#include <QPointer>
2021-05-18 15:59:18 +00:00
#include "constants.h"
2021-05-02 18:22:38 +00:00
class WebsocketClient : public QObject {
Q_OBJECT
public:
explicit WebsocketClient(QObject *parent = nullptr);
void start();
void sendMsg(const QByteArray &data);
QWebSocket webSocket;
signals:
void connectionEstablished();
void WSMessage(QJsonObject message);
private slots:
void onConnected();
2021-10-14 13:41:14 +00:00
void onDisconnected();
2021-05-02 18:22:38 +00:00
void onbinaryMessageReceived(const QByteArray &message);
void onError(QAbstractSocket::SocketError error);
private:
2021-05-18 15:59:18 +00:00
QUrl m_url = constants::websocketUrl;
2021-05-02 18:22:38 +00:00
QTimer m_pingTimer;
};
#endif //FEATHER_WEBSOCKETCLIENT_H