diff options
author | Kurt Pattyn <pattyn.kurt@gmail.com> | 2013-11-17 15:30:34 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-17 15:31:11 +0100 |
commit | b68dcd71d3b73a8d6be57a0001af2d79bce98533 (patch) | |
tree | df11355e2a9de126d8123e4cfb9888eb2f0dc076 | |
parent | d5cc962781407e8a8f6560d5579128ac24c96231 (diff) | |
download | qtwebsockets-b68dcd71d3b73a8d6be57a0001af2d79bce98533.tar.gz |
Add close code and close reason getter functions
Change-Id: I4eeab1521054e4f4921d25c6a990eeb7486443cb
Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
-rw-r--r-- | src/websockets/qwebsocket.cpp | 20 | ||||
-rw-r--r-- | src/websockets/qwebsocket.h | 2 | ||||
-rw-r--r-- | src/websockets/qwebsocket_p.cpp | 20 | ||||
-rw-r--r-- | src/websockets/qwebsocket_p.h | 4 | ||||
-rw-r--r-- | sync.profile | 1 |
5 files changed, 47 insertions, 0 deletions
diff --git a/src/websockets/qwebsocket.cpp b/src/websockets/qwebsocket.cpp index 21b6a35..0d3b23d 100644 --- a/src/websockets/qwebsocket.cpp +++ b/src/websockets/qwebsocket.cpp @@ -509,6 +509,26 @@ QString QWebSocket::extension() const } /*! + \brief Returns the code indicating why the socket was closed. + \sa QWebSocketProtocol::CloseCode, closeReason() + */ +QWebSocketProtocol::CloseCode QWebSocket::closeCode() const +{ + Q_D(const QWebSocket); + return d->closeCode(); +} + +/*! + \brief Returns the reason why the socket was closed. + \sa closeCode() + */ +QString QWebSocket::closeReason() const +{ + Q_D(const QWebSocket); + return d->closeReason(); +} + +/*! \brief Returns the current state of the socket */ QAbstractSocket::SocketState QWebSocket::state() const diff --git a/src/websockets/qwebsocket.h b/src/websockets/qwebsocket.h index f99daad..8a6369a 100644 --- a/src/websockets/qwebsocket.h +++ b/src/websockets/qwebsocket.h @@ -102,6 +102,8 @@ public: QString origin() const; QString protocol() const; QString extension() const; + QWebSocketProtocol::CloseCode closeCode() const; + QString closeReason() const; qint64 write(const char *message); //send data as text qint64 write(const char *message, qint64 maxSize); //send data as text diff --git a/src/websockets/qwebsocket_p.cpp b/src/websockets/qwebsocket_p.cpp index 941366f..87bfa3f 100644 --- a/src/websockets/qwebsocket_p.cpp +++ b/src/websockets/qwebsocket_p.cpp @@ -101,6 +101,8 @@ QWebSocketPrivate::QWebSocketPrivate(const QString &origin, QWebSocketProtocol:: m_mustMask(true), m_isClosingHandshakeSent(false), m_isClosingHandshakeReceived(false), + m_closeCode(QWebSocketProtocol::CC_NORMAL), + m_closeReason(), m_pingTimer(), m_dataProcessor(), m_configuration() @@ -128,6 +130,8 @@ QWebSocketPrivate::QWebSocketPrivate(QTcpSocket *pTcpSocket, QWebSocketProtocol: m_mustMask(true), m_isClosingHandshakeSent(false), m_isClosingHandshakeReceived(false), + m_closeCode(QWebSocketProtocol::CC_NORMAL), + m_closeReason(), m_pingTimer(), m_dataProcessor(), m_configuration() @@ -622,6 +626,22 @@ QString QWebSocketPrivate::extension() const /*! * \internal */ +QWebSocketProtocol::CloseCode QWebSocketPrivate::closeCode() const +{ + return m_closeCode; +} + +/*! + * \internal + */ +QString QWebSocketPrivate::closeReason() const +{ + return m_closeReason; +} + +/*! + * \internal + */ QByteArray QWebSocketPrivate::getFrameHeader(QWebSocketProtocol::OpCode opCode, quint64 payloadLength, quint32 maskingKey, bool lastFrame) const { QByteArray header; diff --git a/src/websockets/qwebsocket_p.h b/src/websockets/qwebsocket_p.h index 80c5e4f..bd41d8b 100644 --- a/src/websockets/qwebsocket_p.h +++ b/src/websockets/qwebsocket_p.h @@ -137,6 +137,8 @@ public: QString origin() const; QString protocol() const; QString extension() const; + QWebSocketProtocol::CloseCode closeCode() const; + QString closeReason() const; qint64 write(const char *message); //send data as text qint64 write(const char *message, qint64 maxSize); //send data as text @@ -223,6 +225,8 @@ private: bool m_isClosingHandshakeSent; bool m_isClosingHandshakeReceived; + QWebSocketProtocol::CloseCode m_closeCode; + QString m_closeReason; QTime m_pingTimer; diff --git a/sync.profile b/sync.profile index ed0c60a..c812830 100644 --- a/sync.profile +++ b/sync.profile @@ -15,4 +15,5 @@ %dependencies = ( "qtbase" => "", + "qtdeclarative" => "", ); |