diff options
author | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2015-08-09 15:27:39 +0200 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2015-08-09 15:27:40 +0200 |
commit | 483fe6ca7b9cc011c648c3cacb48b609d741b407 (patch) | |
tree | 25e51dc1ff62d8516b03c81f8fd8c132dbf2890a | |
parent | 8073e6dc16470c0723cc30c74a2af7fb315733d2 (diff) | |
parent | 0610115192f4a1e4d722330bf298ccd213ca3b5f (diff) | |
download | qtwebsockets-483fe6ca7b9cc011c648c3cacb48b609d741b407.tar.gz |
Merge remote-tracking branch 'origin/5.5' into dev
Change-Id: Ia29cf611432e0be43e0eaf04384e48f68c93af3e
-rw-r--r-- | src/imports/qmlwebsockets/qqmlwebsocketserver.cpp | 12 | ||||
-rw-r--r-- | src/imports/qmlwebsockets/qqmlwebsocketserver.h | 10 | ||||
-rw-r--r-- | tests/auto/qml/qmlwebsockets/tst_qmlwebsockets.qml | 1 |
3 files changed, 15 insertions, 8 deletions
diff --git a/src/imports/qmlwebsockets/qqmlwebsocketserver.cpp b/src/imports/qmlwebsockets/qqmlwebsocketserver.cpp index acaa5cb..ea666a6 100644 --- a/src/imports/qmlwebsockets/qqmlwebsocketserver.cpp +++ b/src/imports/qmlwebsockets/qqmlwebsocketserver.cpp @@ -59,7 +59,9 @@ QT_USE_NAMESPACE /*! \qmlproperty int WebSocketServer::port - The port this server is listening on. By default, a port is chosen automatically. + The port this server is listening on. The value must be in the range 0-65535. + + By default, a port is chosen automatically. */ /*! @@ -144,17 +146,21 @@ void QQmlWebSocketServer::setHost(const QString &host) updateListening(); } -quint16 QQmlWebSocketServer::port() const +int QQmlWebSocketServer::port() const { return m_port; } -void QQmlWebSocketServer::setPort(quint16 port) +void QQmlWebSocketServer::setPort(int port) { if (port == m_port) { return; } + if (port < 0 || port > 65535) { + qWarning() << "QQmlWebSocketServer::setPort: port " << port << " is invalid. It must be in the range 0-65535."; + return; + } m_port = port; emit portChanged(port); emit urlChanged(url()); diff --git a/src/imports/qmlwebsockets/qqmlwebsocketserver.h b/src/imports/qmlwebsockets/qqmlwebsocketserver.h index 4759bc4..5d790db 100644 --- a/src/imports/qmlwebsockets/qqmlwebsocketserver.h +++ b/src/imports/qmlwebsockets/qqmlwebsocketserver.h @@ -49,7 +49,7 @@ class QQmlWebSocketServer : public QObject, public QQmlParserStatus Q_PROPERTY(QUrl url READ url NOTIFY urlChanged) Q_PROPERTY(QString host READ host WRITE setHost NOTIFY hostChanged) - Q_PROPERTY(quint16 port READ port WRITE setPort NOTIFY portChanged) + Q_PROPERTY(int port READ port WRITE setPort NOTIFY portChanged) Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) Q_PROPERTY(QString errorString READ errorString NOTIFY errorStringChanged) Q_PROPERTY(bool listen READ listen WRITE setListen NOTIFY listenChanged) @@ -67,8 +67,8 @@ public: QString host() const; void setHost(const QString &host); - quint16 port() const; - void setPort(quint16 port); + int port() const; + void setPort(int port); QString name() const; void setName(const QString &name); @@ -86,7 +86,7 @@ Q_SIGNALS: void errorStringChanged(const QString &errorString); void urlChanged(const QUrl &url); - void portChanged(quint16 port); + void portChanged(int port); void nameChanged(const QString &name); void hostChanged(const QString &host); void listenChanged(bool listen); @@ -102,7 +102,7 @@ private: QScopedPointer<QWebSocketServer> m_server; QString m_host; QString m_name; - quint16 m_port; + int m_port; bool m_listen; bool m_accept; bool m_componentCompleted; diff --git a/tests/auto/qml/qmlwebsockets/tst_qmlwebsockets.qml b/tests/auto/qml/qmlwebsockets/tst_qmlwebsockets.qml index 6018037..8c721a5 100644 --- a/tests/auto/qml/qmlwebsockets/tst_qmlwebsockets.qml +++ b/tests/auto/qml/qmlwebsockets/tst_qmlwebsockets.qml @@ -44,6 +44,7 @@ Rectangle { WebSocketServer { id: server + port: 1337 } WebSocket { |