diff options
-rw-r--r-- | src/websockets/qwebsocketserver_p.cpp | 6 | ||||
-rw-r--r-- | src/websockets/qwebsocketserver_p.h | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/websockets/qwebsocketserver_p.cpp b/src/websockets/qwebsocketserver_p.cpp index 91bfafc..3bf6d68 100644 --- a/src/websockets/qwebsocketserver_p.cpp +++ b/src/websockets/qwebsocketserver_p.cpp @@ -392,18 +392,20 @@ void QWebSocketServerPrivate::onNewConnection() QObjectPrivate::connect(pTcpSocket, &QTcpSocket::readyRead, this, &QWebSocketServerPrivate::handshakeReceived, Qt::QueuedConnection); + QObjectPrivate::connect(pTcpSocket, &QTcpSocket::disconnected, + this, &QWebSocketServerPrivate::onSocketDisconnected); } } /*! \internal */ -void QWebSocketServerPrivate::onCloseConnection() +void QWebSocketServerPrivate::onSocketDisconnected() { if (Q_LIKELY(currentSender)) { QTcpSocket *pTcpSocket = qobject_cast<QTcpSocket*>(currentSender->sender); if (Q_LIKELY(pTcpSocket)) - pTcpSocket->close(); + pTcpSocket->deleteLater(); } } diff --git a/src/websockets/qwebsocketserver_p.h b/src/websockets/qwebsocketserver_p.h index 46a2156..6aabebd 100644 --- a/src/websockets/qwebsocketserver_p.h +++ b/src/websockets/qwebsocketserver_p.h @@ -136,7 +136,7 @@ private: const QString &errorDescription); void onNewConnection(); - void onCloseConnection(); + void onSocketDisconnected(); void handshakeReceived(); }; |