-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAPIWebsockets.h
More file actions
75 lines (64 loc) · 1.71 KB
/
APIWebsockets.h
File metadata and controls
75 lines (64 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef APIWEBSOCKETS_H
#define APIWEBSOCKETS_H
#include <QtCore/QObject>
#include <QtCore/QList>
#include <QtCore/QByteArray>
#include "MainWidget.h"
QT_FORWARD_DECLARE_CLASS(QWebSocketServer)
QT_FORWARD_DECLARE_CLASS(QWebSocket)
class MainWidget;
/**
* @brief Manages websocket connections with Potree mdInfinity API
*
*/
class APIWebsockets : public QObject
{
Q_OBJECT
public:
/**
* @brief Construct a new APIWebsockets object
*
* Runs a websocket server to listen for Potree mdInfinityAPI
*
* @param port port on which websocket server will run
* @param container MainWidget instance containing this websocket server
* @param parent the parent widget
*/
explicit APIWebsockets(quint16 port, MainWidget *container, QObject *parent = Q_NULLPTR);
/**
* @brief Destroy the APIWebsockets object
*/
virtual ~APIWebsockets();
private Q_SLOTS:
/**
* @brief Done on a new connection
*
* Connects proper slots on 'textMessageReceived' and 'disconnected' signals.
*
*/
void onNewConnection();
/**
* @brief Proceeses received data
*
* Log received data using container log method.
*
* @param data received data
*/
void processData(QString data);
/**
* @brief Closes websocket connection properly
*
*/
void socketDisconnected();
/**
* @brief Sends initialization message to Potree
*
* Provokes Potree to enable point ID selection tool.
*/
void initPointPicking();
private:
QWebSocketServer *m_pWebSocketServer;
QWebSocket *m_client;
MainWidget *m_container;
};
#endif //APIWEBSOCKETS_H