32 lines
740 B
C++
32 lines
740 B
C++
#pragma once
|
|
|
|
#include <QHostAddress>
|
|
#include <QHttpServer>
|
|
#include <QObject>
|
|
#include <QTcpServer>
|
|
|
|
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;
|
|
};
|