Add websocket support

This commit is contained in:
Aditya Kulkarni
2019-01-15 15:10:38 -08:00
parent 5c23be69f8
commit 0e23f137c4
7 changed files with 125 additions and 8 deletions

34
src/websockets.h Normal file
View File

@@ -0,0 +1,34 @@
#ifndef WEBSOCKETS_H
#define WEBSOCKETS_H
#include "mainwindow.h"
#include "precompiled.h"
QT_FORWARD_DECLARE_CLASS(QWebSocketServer)
QT_FORWARD_DECLARE_CLASS(QWebSocket)
class WSServer : public QObject
{
Q_OBJECT
public:
explicit WSServer(quint16 port, bool debug = false, QObject *parent = nullptr);
~WSServer();
Q_SIGNALS:
void closed();
private Q_SLOTS:
void onNewConnection();
void processTextMessage(QString message);
void processBinaryMessage(QByteArray message);
void socketDisconnected();
private:
QWebSocketServer *m_pWebSocketServer;
MainWindow *m_mainWindow;
QList<QWebSocket *> m_clients;
bool m_debug;
};
#endif // WEBSOCKETS_H