Kstars

node.h
1/*
2 SPDX-FileCopyrightText: 2023 Jasem Mutlaq <mutlaqja@ikarustech.com>
3
4 Message Channel
5
6 SPDX-License-Identifier: GPL-2.0-or-later
7*/
8
9#pragma once
10
11#include <QtWebSockets/QWebSocket>
12#include <QJsonObject>
13#include <memory>
14
15namespace EkosLive
16{
17class Node : public QObject
18{
19 Q_PROPERTY(QString name MEMBER m_Name)
20 Q_PROPERTY(QUrl url MEMBER m_URL READ url)
22
23 public:
24 explicit Node(const QString &name);
25 virtual ~Node() = default;
26
27 const QUrl url() const {return m_URL;}
28 void sendResponse(const QString &command, const QJsonObject &payload);
29 void sendResponse(const QString &command, const QJsonArray &payload);
30 void sendResponse(const QString &command, const QString &payload);
31 void sendResponse(const QString &command, bool payload);
32
33 void sendTextMessage(const QString &message);
34 void sendBinaryMessage(const QByteArray &message);
35 bool isConnected() const {return m_isConnected;}
36
37 void setAuthResponse(const QJsonObject &response)
38 {
39 m_AuthResponse = response;
40 }
41
42 signals:
43 void connected();
44 void disconnected();
45 void onTextReceived(const QString &message);
46 void onBinaryReceived(const QByteArray &message);
47
48 public slots:
49 void connectServer();
50 void disconnectServer();
51
52 private slots:
53 // Connection
54 void onConnected();
55 void onDisconnected();
56 void onError(QAbstractSocket::SocketError error);
57
58 private:
59 QWebSocket m_WebSocket;
60 QJsonObject m_AuthResponse;
61 uint16_t m_ReconnectTries {0};
62 QUrl m_URL;
63 QString m_Name;
64 QString m_Path;
65
66 bool m_isConnected { false };
67 bool m_sendBlobs { true};
68
69 QMap<int, bool> m_Options;
70
71 // Retry every 5 seconds in case remote server is down
72 static const uint16_t RECONNECT_INTERVAL = 5000;
73 // Retry for 1 hour before giving up
74 static const uint16_t RECONNECT_MAX_TRIES = 720;
75 // Throttle interval
76 static const uint16_t THROTTLE_INTERVAL = 1000;
77};
78}
Generic record interfaces and implementations.
Definition cloud.cpp:23
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 3 2024 11:49:50 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.