Kstars

wsmedia.h
1/*
2 SPDX-FileCopyrightText: 2019 Jasem Mutlaq <mutlaqja@ikarustech.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include <QtWebSockets/QWebSocket>
10#include <memory>
11
12namespace ISD
13{
14class Camera;
15class WSMedia : public QObject
16{
18
19 public:
20 WSMedia(Camera *manager);
21 virtual ~WSMedia() = default;
22
23 void setURL(const QUrl &url)
24 {
25 m_URL = url;
26 }
27
28 signals:
29 void connected();
30 void disconnected();
31 void newFile(const QByteArray &message, const QString &extension);
32
33 public slots:
34 void connectServer();
35 void disconnectServer();
36
37 private slots:
38
39 // Connection
40 void onConnected();
41 void onDisconnected();
42 void onError(QAbstractSocket::SocketError error);
43
44 // Communication
45 void onTextReceived(const QString &message);
46 void onBinaryReceived(const QByteArray &message);
47
48 private:
49 QWebSocket m_WebSocket;
50 uint16_t m_ReconnectTries {0};
51 Camera *m_Manager { nullptr };
52 QUrl m_URL;
53
54 bool m_isConnected { false };
55 bool m_sendBlobs { true};
56 QString extension;
57
58 // Retry every 5 seconds in case remote server is down
59 static const uint16_t RECONNECT_INTERVAL = 5000;
60 // Retry for 1 hour before giving up
61 static const uint16_t RECONNECT_MAX_TRIES = 720;
62};
63}
ISD is a collection of INDI Standard Devices.
Q_OBJECTQ_OBJECT
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.