- Migrated all 104 CMakeLists.txt files in Lts/Services - Replaced Qt5::Core, Qt5::Gui, Qt5::Widgets, Qt5::Network, Qt5::Svg, Qt5::Concurrent, Qt5::WebSockets, Qt5::Sql, Qt5::Xml, Qt5::Test, Qt5::SerialPort with Qt6:: equivalents - 1244 files modified (CMakeLists.txt and source files) - Zero Qt5:: references remaining in Lts/Services - QTextCodec, QDesktopWidget: No blocking issues found - QRegExp: 7 occurrences remain (deprecated but functional) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
51 lines
1.2 KiB
C++
Executable File
51 lines
1.2 KiB
C++
Executable File
/**
|
|
* WebSocketServer to publish Events
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Christian Ehrlicher, SLSE, 2017-02-06
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <QMap>
|
|
#include <QObject>
|
|
#include <QSet>
|
|
#include <QSqlDatabase>
|
|
#include <QVector>
|
|
#include <ExerciseEventManagement/eem_db_structs.h>
|
|
#include "logger.h"
|
|
|
|
class QTimer;
|
|
class QUrl;
|
|
class QWebSocket;
|
|
class QWebSocketServer;
|
|
namespace ExerciseEventManagement
|
|
{
|
|
class WebSocketEventServer : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
WebSocketEventServer(const QSqlDatabase &db, QObject *parent = nullptr);
|
|
~WebSocketEventServer();
|
|
|
|
bool listen(const QPair<quint16, quint16> &portRange);
|
|
bool listen(quint16 port);
|
|
quint16 listenPort() const;
|
|
|
|
void sendEvent(const QJsonObject &obj);
|
|
private:
|
|
void onNewConnection();
|
|
void onSocketDisconnected();
|
|
void onCleanupLiveHistory();
|
|
void historyDataRequested(const QSqlDatabase &db, QWebSocket *ws, const QUrl &requestUrl);
|
|
private:
|
|
QSet<QWebSocket *> m_liveSockets;
|
|
QMap<qint64, QVector<QString>> m_liveHistory;
|
|
QWebSocketServer *m_wsServer;
|
|
QTimer *m_cleanupTimer;
|
|
QSqlDatabase m_db;
|
|
NGL::INGLLogger &m_logger;
|
|
};
|
|
} // namespace ExerciseEventManagement
|