diff options
author | Sergio Ahumada <sahumada@blackberry.com> | 2014-03-13 14:50:03 +0100 |
---|---|---|
committer | Sergio Ahumada <sahumada@blackberry.com> | 2014-03-13 14:50:05 +0100 |
commit | 974fd5f831cf9abfbd900c49ab6c21fb04ef62da (patch) | |
tree | 235666b5d896d5c86db5325215720425b5508ffa /examples | |
parent | e677361e300a7747a500c3879217727a53aae245 (diff) | |
parent | d4ac9f51f6d18a05016e3d61c06eace27501f589 (diff) | |
download | qtwebsockets-974fd5f831cf9abfbd900c49ab6c21fb04ef62da.tar.gz |
Merge remote-tracking branch 'origin/stable' into dev
Change-Id: I0ee590f834200c488498315e66acf7cd046d43ad
Diffstat (limited to 'examples')
-rw-r--r-- | examples/doc/echoclient.qdoc | 5 | ||||
-rw-r--r-- | examples/doc/echoserver.qdoc | 6 | ||||
-rw-r--r-- | examples/doc/qmlwebsocketclient.qdoc | 1 | ||||
-rw-r--r-- | examples/doc/simplechat.qdoc | 5 | ||||
-rw-r--r-- | examples/doc/sslechoclient.qdoc | 2 | ||||
-rw-r--r-- | examples/doc/sslechoserver.qdoc | 2 | ||||
-rw-r--r-- | examples/examples.qdoc | 3 | ||||
-rw-r--r-- | examples/sslechoclient/sslechoclient.cpp | 17 | ||||
-rw-r--r-- | examples/sslechoclient/sslechoclient.h | 9 |
9 files changed, 40 insertions, 10 deletions
diff --git a/examples/doc/echoclient.qdoc b/examples/doc/echoclient.qdoc index a1f1646..a6cb1a9 100644 --- a/examples/doc/echoclient.qdoc +++ b/examples/doc/echoclient.qdoc @@ -43,7 +43,10 @@ \example echoclient \title Echo Client Example \ingroup qtwebsockets-examples - \brief Explains how to use the websocket API to create a simple echo client. + \brief Describes how to use the websocket API for creating a simple echo client. + + The Echo Client Example shows how to use the websocket API to create a simple + echo client. \sa {Echo Server Example} */ diff --git a/examples/doc/echoserver.qdoc b/examples/doc/echoserver.qdoc index b7b8299..fcb0442 100644 --- a/examples/doc/echoserver.qdoc +++ b/examples/doc/echoserver.qdoc @@ -43,9 +43,11 @@ \example echoserver \title Echo Server Example \ingroup qtwebsockets-examples + \brief Shows how to create a simple server application that + sends back the messages it receives. - The Echo Server example shows how to create a simple server application that - sends back the messages that it receives, using the websockets API. + The Echo Server Example shows how to create a simple server application that + sends back the messages it receives, using the websockets API. \sa {Echo Client Example} */ diff --git a/examples/doc/qmlwebsocketclient.qdoc b/examples/doc/qmlwebsocketclient.qdoc index 0bf39bd..776e486 100644 --- a/examples/doc/qmlwebsocketclient.qdoc +++ b/examples/doc/qmlwebsocketclient.qdoc @@ -43,4 +43,5 @@ \example qmlwebsocketclient \title QML WebSocket Client Example \ingroup qtwebsockets-examples + \brief Explains how to program a QML WebSocket client example. */ diff --git a/examples/doc/simplechat.qdoc b/examples/doc/simplechat.qdoc index 215c46a..506d45a 100644 --- a/examples/doc/simplechat.qdoc +++ b/examples/doc/simplechat.qdoc @@ -43,7 +43,10 @@ \example simplechat \title Simple Chat Example \ingroup qtwebsockets-examples + \brief Shows how to use the QWebSocket and QWebSocketServer classes + for creating a minimalistic chat application over websockets. - The Simple Chat example shows how to use the QWebSocket and QWebSocketServer + The Simple Chat Example shows how to use the QWebSocket and QWebSocketServer classes to create a minimalistic chat application over websockets. + */ diff --git a/examples/doc/sslechoclient.qdoc b/examples/doc/sslechoclient.qdoc index ca515ec..d7d1897 100644 --- a/examples/doc/sslechoclient.qdoc +++ b/examples/doc/sslechoclient.qdoc @@ -43,6 +43,8 @@ \example sslechoclient \title SSL Echo Client Example \ingroup qtwebsockets-examples + \brief Shows how to use the QWebSocket class to implement an echo + client over a secure connection (wss). The SSL Echo Client example shows how to use the QWebSocket class to implement an echo client over a secure connection (wss). diff --git a/examples/doc/sslechoserver.qdoc b/examples/doc/sslechoserver.qdoc index 608b27a..d158a68 100644 --- a/examples/doc/sslechoserver.qdoc +++ b/examples/doc/sslechoserver.qdoc @@ -43,6 +43,8 @@ \example sslechoserver \title SSL Echo Server Example \ingroup qtwebsockets-examples + \brief Shows how to use the QWebSocketServer class for implementing a simple + echo server over secure sockets (wss). The SSL Echo Server example shows how to use the QWebSocketServer class to implement a simple echo server over secure sockets (wss). diff --git a/examples/examples.qdoc b/examples/examples.qdoc index b770704..bc1ad32 100644 --- a/examples/examples.qdoc +++ b/examples/examples.qdoc @@ -45,8 +45,7 @@ \page examples.html \brief List of Qt WebSocket examples - The module provides the following examples for reference to - help understand the API usage: + The examples below can be used as a guide to using the API. \list \li \l echoclient diff --git a/examples/sslechoclient/sslechoclient.cpp b/examples/sslechoclient/sslechoclient.cpp index fdf00df..037990d 100644 --- a/examples/sslechoclient/sslechoclient.cpp +++ b/examples/sslechoclient/sslechoclient.cpp @@ -40,6 +40,8 @@ ****************************************************************************/ #include "sslechoclient.h" #include <QtCore/QDebug> +#include <QtWebSockets/QWebSocket> +#include <QCoreApplication> QT_USE_NAMESPACE @@ -49,6 +51,9 @@ SslEchoClient::SslEchoClient(const QUrl &url, QObject *parent) : m_webSocket() { connect(&m_webSocket, &QWebSocket::connected, this, &SslEchoClient::onConnected); + typedef void (QWebSocket:: *sslErrorsSignal)(const QList<QSslError> &); + connect(&m_webSocket, static_cast<sslErrorsSignal>(&QWebSocket::sslErrors), + this, &SslEchoClient::onSslErrors); m_webSocket.open(QUrl(url)); } //! [constructor] @@ -67,5 +72,17 @@ void SslEchoClient::onConnected() void SslEchoClient::onTextMessageReceived(QString message) { qDebug() << "Message received:" << message; + qApp->quit(); +} + +void SslEchoClient::onSslErrors(const QList<QSslError> &errors) +{ + Q_UNUSED(errors); + + // WARNING: Never ignore SSL errors in production code. + // The proper way to handle self-signed certificates is to add a custom root + // to the CA store. + + m_webSocket.ignoreSslErrors(); } //! [onTextMessageReceived] diff --git a/examples/sslechoclient/sslechoclient.h b/examples/sslechoclient/sslechoclient.h index cec9e9d..7ec373b 100644 --- a/examples/sslechoclient/sslechoclient.h +++ b/examples/sslechoclient/sslechoclient.h @@ -43,6 +43,10 @@ #include <QtCore/QObject> #include <QtWebSockets/QWebSocket> +#include <QtNetwork/QSslError> +#include <QtCore/QList> +#include <QtCore/QString> +#include <QtCore/QUrl> QT_FORWARD_DECLARE_CLASS(QWebSocket) @@ -52,13 +56,10 @@ class SslEchoClient : public QObject public: explicit SslEchoClient(const QUrl &url, QObject *parent = Q_NULLPTR); -Q_SIGNALS: - -public Q_SLOTS: - private Q_SLOTS: void onConnected(); void onTextMessageReceived(QString message); + void onSslErrors(const QList<QSslError> &errors); private: QWebSocket m_webSocket; |