diff options
author | Arno Rehn <a.rehn@menlosystems.com> | 2022-01-02 22:31:03 +0100 |
---|---|---|
committer | Arno Rehn <a.rehn@menlosystems.com> | 2022-03-30 17:45:18 +0200 |
commit | cc4c24b99a87629aeb60df5af96d9bb991b56635 (patch) | |
tree | 62459a42457b0680022bb1fcb759f9c4e64d2c4b /src/imports/qmlwebsockets/qqmlwebsocket.h | |
parent | 8545bb57efbfabf0dc7bc4b76efd6a99b4022669 (diff) | |
download | qtwebsockets-cc4c24b99a87629aeb60df5af96d9bb991b56635.tar.gz |
Add support for WebSocket Sub-Protocols
Sub-Protocol support follows RFC 6455 Sections 4.1 and 4.2. See also
https://datatracker.ietf.org/doc/html/rfc6455.
This patch introduces a new class QWebSocketHandshakeOptions which
collects options for the WebSocket handshake. At the moment, this
contains only accessors for sub-protocols. In the future, it can be
extended with things like WebSocket extensions.
[ChangeLog] Add support for WebSocket Sub-Protocols
Fixes: QTBUG-38742
Change-Id: Ibdcef17f717f0a76caab54f65c550865df1ec78d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/imports/qmlwebsockets/qqmlwebsocket.h')
-rw-r--r-- | src/imports/qmlwebsockets/qqmlwebsocket.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/imports/qmlwebsockets/qqmlwebsocket.h b/src/imports/qmlwebsockets/qqmlwebsocket.h index 7662607..1cd28c4 100644 --- a/src/imports/qmlwebsockets/qqmlwebsocket.h +++ b/src/imports/qmlwebsockets/qqmlwebsocket.h @@ -55,9 +55,13 @@ class QQmlWebSocket : public QObject, public QQmlParserStatus Q_INTERFACES(QQmlParserStatus) Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged) + Q_PROPERTY(QStringList requestedSubprotocols READ requestedSubprotocols + WRITE setRequestedSubprotocols NOTIFY requestedSubprotocolsChanged) Q_PROPERTY(Status status READ status NOTIFY statusChanged) Q_PROPERTY(QString errorString READ errorString NOTIFY errorStringChanged) Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged) + Q_PROPERTY(QString negotiatedSubprotocol READ negotiatedSubprotocol + NOTIFY negotiatedSubprotocolChanged) public: explicit QQmlWebSocket(QObject *parent = 0); @@ -76,6 +80,10 @@ public: QUrl url() const; void setUrl(const QUrl &url); + QStringList requestedSubprotocols() const; + void setRequestedSubprotocols(const QStringList &subprotocols); + + QString negotiatedSubprotocol() const; Status status() const; QString errorString() const; @@ -92,6 +100,8 @@ Q_SIGNALS: void activeChanged(bool isActive); void errorStringChanged(QString errorString); void urlChanged(); + void requestedSubprotocolsChanged(); + void negotiatedSubprotocolChanged(); public: void classBegin() override; @@ -103,8 +113,10 @@ private Q_SLOTS: private: QScopedPointer<QWebSocket> m_webSocket; + QString m_negotiatedProtocol; Status m_status; QUrl m_url; + QStringList m_requestedProtocols; bool m_isActive; bool m_componentCompleted; QString m_errorString; |