diff options
Diffstat (limited to 'src')
6 files changed, 27 insertions, 10 deletions
diff --git a/src/plugins/platforms/webgl/qwebglintegration.cpp b/src/plugins/platforms/webgl/qwebglintegration.cpp index 1b4214a..08a432c 100644 --- a/src/plugins/platforms/webgl/qwebglintegration.cpp +++ b/src/plugins/platforms/webgl/qwebglintegration.cpp @@ -70,12 +70,13 @@ QWebGLIntegrationPrivate *QWebGLIntegrationPrivate::instance() return static_cast<QWebGLIntegration *>(platformIntegration)->d_ptr.data(); } -QWebGLIntegration::QWebGLIntegration(quint16 port) : +QWebGLIntegration::QWebGLIntegration(quint16 port, quint16 wssport) : d_ptr(new QWebGLIntegrationPrivate) { Q_D(QWebGLIntegration); d->q_ptr = this; d->httpPort = port; + d->wssPort = wssport; d->touchDevice = new QTouchDevice; d->touchDevice->setName("EmulatedTouchDevice"); d->touchDevice->setType(QTouchDevice::TouchScreen); @@ -112,7 +113,7 @@ void QWebGLIntegration::initialize() d->screen = new QWebGLScreen; screenAdded(d->screen, true); - d->webSocketServer = new QWebGLWebSocketServer; + d->webSocketServer = new QWebGLWebSocketServer(d->wssPort); d->httpServer = new QWebGLHttpServer(d->webSocketServer, this); bool ok = d->httpServer->listen(QHostAddress::Any, d->httpPort); if (!ok) { diff --git a/src/plugins/platforms/webgl/qwebglintegration.h b/src/plugins/platforms/webgl/qwebglintegration.h index 856ccde..f3e22df 100644 --- a/src/plugins/platforms/webgl/qwebglintegration.h +++ b/src/plugins/platforms/webgl/qwebglintegration.h @@ -45,7 +45,7 @@ Q_DECLARE_LOGGING_CATEGORY(lcWebGL) class QWebGLIntegration : public QPlatformIntegration, public QPlatformNativeInterface { public: - QWebGLIntegration(quint16 port); + QWebGLIntegration(quint16 port, quint16 wssport); ~QWebGLIntegration(); static QWebGLIntegration *instance(); diff --git a/src/plugins/platforms/webgl/qwebglintegration_p.h b/src/plugins/platforms/webgl/qwebglintegration_p.h index 06f19fc..106667e 100644 --- a/src/plugins/platforms/webgl/qwebglintegration_p.h +++ b/src/plugins/platforms/webgl/qwebglintegration_p.h @@ -71,6 +71,7 @@ public: mutable QPlatformInputContext *inputContext = nullptr; quint16 httpPort = 0; + quint16 wssPort = 0; #if defined(Q_OS_WIN) mutable QWindowsFontDatabase fontDatabase; #elif defined(Q_OS_MACOS) diff --git a/src/plugins/platforms/webgl/qwebglmain.cpp b/src/plugins/platforms/webgl/qwebglmain.cpp index 6c9c324..ec3e8e5 100644 --- a/src/plugins/platforms/webgl/qwebglmain.cpp +++ b/src/plugins/platforms/webgl/qwebglmain.cpp @@ -47,6 +47,8 @@ QPlatformIntegration* QWebGLIntegrationPlugin::create(const QString& system, const QStringList& paramList) { quint16 port = 8080; + quint16 wssport = 0; + if (!paramList.isEmpty()) { for (const QString ¶meter : qAsConst(paramList)) { const QStringList parts = parameter.split('='); @@ -61,13 +63,23 @@ QPlatformIntegration* QWebGLIntegrationPlugin::create(const QString& system, qCCritical(lcWebGL, "Invalid port number"); return nullptr; } - } - if (parts.first() == QStringLiteral("noloadingscreen")) + } else if (parts.first() == QStringLiteral("wsserverport")) { + if (parts.size() != 2) { + qCCritical(lcWebGL, "Websocket server port specified with no value"); + return nullptr; + } + bool ok; + wssport = parts.last().toUShort(&ok); + if (!ok) { + qCCritical(lcWebGL, "Invalid websocket port number"); + return nullptr; + } + } else if (parts.first() == QStringLiteral("noloadingscreen")) qputenv("QT_WEBGL_LOADINGSCREEN", "0"); } } if (!system.compare(QLatin1String("webgl"), Qt::CaseInsensitive)) - return new QWebGLIntegration(port); + return new QWebGLIntegration(port, wssport); return nullptr; } diff --git a/src/plugins/platforms/webgl/qwebglwebsocketserver.cpp b/src/plugins/platforms/webgl/qwebglwebsocketserver.cpp index dfeaa58..c7fab3b 100644 --- a/src/plugins/platforms/webgl/qwebglwebsocketserver.cpp +++ b/src/plugins/platforms/webgl/qwebglwebsocketserver.cpp @@ -70,12 +70,15 @@ class QWebGLWebSocketServerPrivate { public: QWebSocketServer *server = nullptr; + quint16 initialPort = 0; }; -QWebGLWebSocketServer::QWebGLWebSocketServer(QObject *parent) : +QWebGLWebSocketServer::QWebGLWebSocketServer(quint16 port, QObject *parent) : QObject(parent), d_ptr(new QWebGLWebSocketServerPrivate) -{} +{ + d_ptr->initialPort = port; +} QWebGLWebSocketServer::~QWebGLWebSocketServer() {} @@ -120,7 +123,7 @@ void QWebGLWebSocketServer::create() #endif QWebSocketServer::NonSecureMode); } - if (d->server->listen(hostAddress, url.port(0))) { + if (d->server->listen(hostAddress, url.port(d->initialPort))) { connect(d->server, &QWebSocketServer::newConnection, this, &QWebGLWebSocketServer::onNewConnection); } else { diff --git a/src/plugins/platforms/webgl/qwebglwebsocketserver.h b/src/plugins/platforms/webgl/qwebglwebsocketserver.h index f2bbea0..9330ec0 100644 --- a/src/plugins/platforms/webgl/qwebglwebsocketserver.h +++ b/src/plugins/platforms/webgl/qwebglwebsocketserver.h @@ -55,7 +55,7 @@ public: ChangeTitle }; - QWebGLWebSocketServer(QObject *parent = nullptr); + QWebGLWebSocketServer(quint16 port, QObject *parent = nullptr); ~QWebGLWebSocketServer() override; quint16 port() const; |