diff options
author | Lorn Potter <lorn.potter@gmail.com> | 2018-12-19 12:01:44 +1000 |
---|---|---|
committer | Lorn Potter <lorn.potter@gmail.com> | 2019-01-04 22:39:33 +0000 |
commit | 16bfc98a03186cef5aafa79709b086faa0d4f9f2 (patch) | |
tree | 7b53ae2bb8d491c1daaf2cfc7f0f38a4c1fe3545 /src | |
parent | a53a28b971e3ae1a4a2baf7320ba60f5077f5596 (diff) | |
download | qtwebsockets-16bfc98a03186cef5aafa79709b086faa0d4f9f2.tar.gz |
wasm: set and update socket state
Fixes: QTBUG-72664
Change-Id: I8bd90f8676835d8f7bec135ad3e6c6b3e9cd9d9a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/websockets/qwebsocket_p.h | 2 | ||||
-rw-r--r-- | src/websockets/qwebsocket_wasm_p.cpp | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/src/websockets/qwebsocket_p.h b/src/websockets/qwebsocket_p.h index fd631d4..4b39dfc 100644 --- a/src/websockets/qwebsocket_p.h +++ b/src/websockets/qwebsocket_p.h @@ -158,6 +158,7 @@ public: void close(QWebSocketProtocol::CloseCode closeCode, QString reason); void open(const QNetworkRequest &request, bool mask); void ping(const QByteArray &payload); + void setSocketState(QAbstractSocket::SocketState state); private: QWebSocketPrivate(QTcpSocket *pTcpSocket, QWebSocketProtocol::Version version); @@ -168,7 +169,6 @@ private: void setProtocol(const QString &protocol); void setExtension(const QString &extension); void enableMasking(bool enable); - void setSocketState(QAbstractSocket::SocketState state); void setErrorString(const QString &errorString); void socketDestroyed(QObject *socket); diff --git a/src/websockets/qwebsocket_wasm_p.cpp b/src/websockets/qwebsocket_wasm_p.cpp index 2ac61ba..922d6a8 100644 --- a/src/websockets/qwebsocket_wasm_p.cpp +++ b/src/websockets/qwebsocket_wasm_p.cpp @@ -63,6 +63,7 @@ static void q_onCloseCallback(val event) QWebSocketPrivate *wsp = reinterpret_cast<QWebSocketPrivate*>(target["data-context"].as<quintptr>()); Q_ASSERT (wsp); + wsp->setSocketState(QAbstractSocket::UnconnectedState); emit wsp->q_func()->disconnected(); } @@ -73,6 +74,7 @@ static void q_onOpenCallback(val event) QWebSocketPrivate *wsp = reinterpret_cast<QWebSocketPrivate*>(target["data-context"].as<quintptr>()); Q_ASSERT (wsp); + wsp->setSocketState(QAbstractSocket::ConnectedState); emit wsp->q_func()->connected(); } @@ -149,6 +151,7 @@ void QWebSocketPrivate::close(QWebSocketProtocol::CloseCode closeCode, QString r m_closeCode = closeCode; m_closeReason = reason; Q_EMIT q->aboutToClose(); + setSocketState(QAbstractSocket::ClosingState); socketContext.call<void>("close", static_cast<quint16>(closeCode), reason.toLatin1().toStdString()); @@ -165,6 +168,7 @@ void QWebSocketPrivate::open(const QNetworkRequest &request, bool mask) return; } + setSocketState(QAbstractSocket::ConnectingState); const std::string urlbytes = url.toString().toStdString(); // HTML WebSockets do not support arbitrary request headers, but |