forked from dresden-elektronik/deconz-rest-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebsocket_server.h
More file actions
41 lines (32 loc) · 812 Bytes
/
websocket_server.h
File metadata and controls
41 lines (32 loc) · 812 Bytes
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
#ifndef WEBSOCKET_SERVER_H
#define WEBSOCKET_SERVER_H
#include <QObject>
#include <vector>
#ifdef USE_WEBSOCKETS
#include <QWebSocket>
#include <QWebSocketServer>
#endif // USE_WEBSOCKETS
class QWebSocket;
class QWebSocketServer;
/*! \class WebSocketServer
Basic websocket server to broadcast messages to clients.
*/
class WebSocketServer : public QObject
{
Q_OBJECT
public:
explicit WebSocketServer(QObject *parent, quint16 port);
quint16 port() const;
signals:
public slots:
void broadcastTextMessage(const QString &msg);
void flush();
private slots:
void onNewConnection();
void onSocketDisconnected();
void onSocketError(QAbstractSocket::SocketError err);
private:
QWebSocketServer *srv;
std::vector<QWebSocket*> clients;
};
#endif // WEBSOCKET_SERVER_H