summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKurt Pattyn <pattyn.kurt@gmail.com>2013-11-17 15:30:34 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-17 15:31:11 +0100
commitb68dcd71d3b73a8d6be57a0001af2d79bce98533 (patch)
treedf11355e2a9de126d8123e4cfb9888eb2f0dc076
parentd5cc962781407e8a8f6560d5579128ac24c96231 (diff)
downloadqtwebsockets-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.cpp20
-rw-r--r--src/websockets/qwebsocket.h2
-rw-r--r--src/websockets/qwebsocket_p.cpp20
-rw-r--r--src/websockets/qwebsocket_p.h4
-rw-r--r--sync.profile1
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" => "",
);