fix websocket disconnections
This commit is contained in:
parent
99aa833ce8
commit
b97887b9fb
@ -672,6 +672,7 @@ void JsonRPCServer::clientConnected(const QUuid &clientId)
|
|||||||
|
|
||||||
void JsonRPCServer::clientDisconnected(const QUuid &clientId)
|
void JsonRPCServer::clientDisconnected(const QUuid &clientId)
|
||||||
{
|
{
|
||||||
|
qCDebug(dcJsonRpc()) << "Client disconnected:" << clientId;
|
||||||
m_clientTransports.remove(clientId);
|
m_clientTransports.remove(clientId);
|
||||||
m_clientNotifications.remove(clientId);
|
m_clientNotifications.remove(clientId);
|
||||||
if (m_pushButtonTransactions.values().contains(clientId)) {
|
if (m_pushButtonTransactions.values().contains(clientId)) {
|
||||||
|
|||||||
@ -126,7 +126,6 @@ void WebSocketServer::onClientConnected()
|
|||||||
{
|
{
|
||||||
// got a new client connected
|
// got a new client connected
|
||||||
QWebSocket *client = m_server->nextPendingConnection();
|
QWebSocket *client = m_server->nextPendingConnection();
|
||||||
qCDebug(dcConnection) << "Websocket server: new client connected:" << client->peerAddress().toString();
|
|
||||||
|
|
||||||
// check websocket version
|
// check websocket version
|
||||||
if (client->version() != QWebSocketProtocol::Version13) {
|
if (client->version() != QWebSocketProtocol::Version13) {
|
||||||
@ -138,6 +137,8 @@ void WebSocketServer::onClientConnected()
|
|||||||
|
|
||||||
QUuid clientId = QUuid::createUuid();
|
QUuid clientId = QUuid::createUuid();
|
||||||
|
|
||||||
|
qCDebug(dcConnection) << "Websocket server: new client connected:" << client->peerAddress().toString() << clientId;
|
||||||
|
|
||||||
// append the new client to the client list
|
// append the new client to the client list
|
||||||
m_clientList.insert(clientId, client);
|
m_clientList.insert(clientId, client);
|
||||||
|
|
||||||
@ -153,9 +154,10 @@ void WebSocketServer::onClientConnected()
|
|||||||
void WebSocketServer::onClientDisconnected()
|
void WebSocketServer::onClientDisconnected()
|
||||||
{
|
{
|
||||||
QWebSocket *client = qobject_cast<QWebSocket *>(sender());
|
QWebSocket *client = qobject_cast<QWebSocket *>(sender());
|
||||||
qCDebug(dcConnection) << "Websocket server: client disconnected:" << client->peerAddress().toString();
|
|
||||||
QUuid clientId = m_clientList.key(client);
|
QUuid clientId = m_clientList.key(client);
|
||||||
|
qCDebug(dcConnection) << "Websocket server: client disconnected:" << client->peerAddress().toString() << clientId;
|
||||||
m_clientList.take(clientId)->deleteLater();
|
m_clientList.take(clientId)->deleteLater();
|
||||||
|
emit clientDisconnected(clientId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebSocketServer::onBinaryMessageReceived(const QByteArray &data)
|
void WebSocketServer::onBinaryMessageReceived(const QByteArray &data)
|
||||||
|
|||||||
Reference in New Issue
Block a user