#pragma once #include #include #include #include class QWebSocket; class Application final : public QObject { Q_OBJECT public: explicit Application(QObject *parent = nullptr); [[nodiscard]] bool start(const QHostAddress &address, quint16 port); [[nodiscard]] quint16 port() const { return m_tcpServer.serverPort(); } private slots: void acceptWebSocket(); private: void configureHttpRoutes(); [[nodiscard]] static QHttpServerResponse resourceResponse(const QString &path, const QByteArray &mimeType); static void applySecurityHeaders(QHttpServerResponse &response); QHttpServer m_httpServer; QTcpServer m_tcpServer; };