Kstars

wsmedia.h
1 /*
2  SPDX-FileCopyrightText: 2019 Jasem Mutlaq <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include <QtWebSockets/QWebSocket>
10 #include <memory>
11 
12 namespace ISD
13 {
14 class Camera;
15 class WSMedia : public QObject
16 {
17  Q_OBJECT
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 }
Q_OBJECTQ_OBJECT
QString message
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 12 2022 04:00:58 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.