summaryrefslogtreecommitdiff
path: root/examples/websockets
diff options
context:
space:
mode:
Diffstat (limited to 'examples/websockets')
-rw-r--r--examples/websockets/echoserver/echoserver.cpp1
-rw-r--r--examples/websockets/simplechat/chatserver.cpp6
-rw-r--r--examples/websockets/sslechoclient/sslechoclient.cpp3
-rw-r--r--examples/websockets/sslechoserver/sslechoserver.cpp4
-rw-r--r--examples/websockets/websockets.pro3
5 files changed, 6 insertions, 11 deletions
diff --git a/examples/websockets/echoserver/echoserver.cpp b/examples/websockets/echoserver/echoserver.cpp
index 013ddc2..d4e3b65 100644
--- a/examples/websockets/echoserver/echoserver.cpp
+++ b/examples/websockets/echoserver/echoserver.cpp
@@ -59,7 +59,6 @@ EchoServer::EchoServer(quint16 port, bool debug, QObject *parent) :
QObject(parent),
m_pWebSocketServer(new QWebSocketServer(QStringLiteral("Echo Server"),
QWebSocketServer::NonSecureMode, this)),
- m_clients(),
m_debug(debug)
{
if (m_pWebSocketServer->listen(QHostAddress::Any, port)) {
diff --git a/examples/websockets/simplechat/chatserver.cpp b/examples/websockets/simplechat/chatserver.cpp
index 33e5d8d..ae207f5 100644
--- a/examples/websockets/simplechat/chatserver.cpp
+++ b/examples/websockets/simplechat/chatserver.cpp
@@ -57,8 +57,7 @@ QT_USE_NAMESPACE
//! [constructor]
ChatServer::ChatServer(quint16 port, QObject *parent) :
QObject(parent),
- m_pWebSocketServer(Q_NULLPTR),
- m_clients()
+ m_pWebSocketServer(Q_NULLPTR)
{
m_pWebSocketServer = new QWebSocketServer(QStringLiteral("Chat Server"),
QWebSocketServer::NonSecureMode,
@@ -94,8 +93,7 @@ void ChatServer::onNewConnection()
void ChatServer::processMessage(QString message)
{
QWebSocket *pSender = qobject_cast<QWebSocket *>(sender());
- Q_FOREACH (QWebSocket *pClient, m_clients)
- {
+ for (QWebSocket *pClient : qAsConst(m_clients)) {
if (pClient != pSender) //don't echo message back to sender
{
pClient->sendTextMessage(message);
diff --git a/examples/websockets/sslechoclient/sslechoclient.cpp b/examples/websockets/sslechoclient/sslechoclient.cpp
index cb15e35..3de2fec 100644
--- a/examples/websockets/sslechoclient/sslechoclient.cpp
+++ b/examples/websockets/sslechoclient/sslechoclient.cpp
@@ -56,8 +56,7 @@ QT_USE_NAMESPACE
//! [constructor]
SslEchoClient::SslEchoClient(const QUrl &url, QObject *parent) :
- QObject(parent),
- m_webSocket()
+ QObject(parent)
{
connect(&m_webSocket, &QWebSocket::connected, this, &SslEchoClient::onConnected);
typedef void (QWebSocket:: *sslErrorsSignal)(const QList<QSslError> &);
diff --git a/examples/websockets/sslechoserver/sslechoserver.cpp b/examples/websockets/sslechoserver/sslechoserver.cpp
index 777d8dd..ae5d9ad 100644
--- a/examples/websockets/sslechoserver/sslechoserver.cpp
+++ b/examples/websockets/sslechoserver/sslechoserver.cpp
@@ -60,8 +60,7 @@ QT_USE_NAMESPACE
//! [constructor]
SslEchoServer::SslEchoServer(quint16 port, QObject *parent) :
QObject(parent),
- m_pWebSocketServer(Q_NULLPTR),
- m_clients()
+ m_pWebSocketServer(Q_NULLPTR)
{
m_pWebSocketServer = new QWebSocketServer(QStringLiteral("SSL Echo Server"),
QWebSocketServer::SecureMode,
@@ -109,7 +108,6 @@ void SslEchoServer::onNewConnection()
connect(pSocket, &QWebSocket::binaryMessageReceived,
this, &SslEchoServer::processBinaryMessage);
connect(pSocket, &QWebSocket::disconnected, this, &SslEchoServer::socketDisconnected);
- //connect(pSocket, &QWebSocket::pong, this, &SslEchoServer::processPong);
m_clients << pSocket;
}
diff --git a/examples/websockets/websockets.pro b/examples/websockets/websockets.pro
index e5eddf6..fa6c0c0 100644
--- a/examples/websockets/websockets.pro
+++ b/examples/websockets/websockets.pro
@@ -1,4 +1,5 @@
TEMPLATE = subdirs
+QT_FOR_CONFIG += network
SUBDIRS = echoclient \
echoserver \
@@ -9,7 +10,7 @@ SUBDIRS += qmlwebsocketclient \
qmlwebsocketserver
}
-contains(QT_CONFIG, openssl) | contains(QT_CONFIG, openssl-linked) {
+qtConfig(ssl) {
SUBDIRS += \
sslechoserver \
sslechoclient