Tell the server if a client has been disconnected without notice
This commit is contained in:
parent
19e85d509e
commit
eb609da9a4
@ -244,7 +244,7 @@ void JsonRpcServer::processDataPacket(TransportClient *transportClient, const QB
|
|||||||
}
|
}
|
||||||
|
|
||||||
JsonReply *reply;
|
JsonReply *reply;
|
||||||
QMetaObject::invokeMethod(handler, method.toLatin1().data(), Q_RETURN_ARG(JsonReply*, reply), Q_ARG(QVariantMap, params), Q_ARG(TransportClient *, transportClient));
|
QMetaObject::invokeMethod(handler, method.toLatin1().data(), Q_RETURN_ARG(JsonReply*, reply), Q_ARG(QVariantMap, params), Q_ARG(TransportClient*, transportClient));
|
||||||
if (reply->type() == JsonReply::TypeAsync) {
|
if (reply->type() == JsonReply::TypeAsync) {
|
||||||
m_asyncReplies.insert(reply, transportClient);
|
m_asyncReplies.insert(reply, transportClient);
|
||||||
reply->setClientId(transportClient->clientId());
|
reply->setClientId(transportClient->clientId());
|
||||||
@ -297,24 +297,25 @@ void JsonRpcServer::asyncReplyFinished()
|
|||||||
qCWarning(dcJsonRpc()) << "Return value validation failed. This should never happen. Please check the source code.";
|
qCWarning(dcJsonRpc()) << "Return value validation failed. This should never happen. Please check the source code.";
|
||||||
}
|
}
|
||||||
|
|
||||||
sendResponse(transportClient, reply->commandId(), reply->data());
|
|
||||||
|
|
||||||
if (!reply->success()) {
|
if (!reply->success()) {
|
||||||
// Disconnect this client since the request was not successfully
|
// Disconnect this client since the request was not successfully
|
||||||
transportClient->killConnectionAfterResponse("API call was not successfully.");
|
transportClient->killConnectionAfterResponse("API call was not successfully.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sendResponse(transportClient, reply->commandId(), reply->data());
|
||||||
// If the server decided to kill the connection after the response, do it now
|
|
||||||
if (transportClient->killConnectionRequested()) {
|
|
||||||
transportClient->killConnection(transportClient->killConnectionReason());
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
qCWarning(dcJsonRpc()) << "The reply timeouted.";
|
qCWarning(dcJsonRpc()) << "The reply timeouted.";
|
||||||
|
transportClient->killConnectionAfterResponse("API call timeouted.");
|
||||||
sendErrorResponse(transportClient, reply->commandId(), "Command timed out");
|
sendErrorResponse(transportClient, reply->commandId(), "Command timed out");
|
||||||
// Disconnect this client since he requested something that created a timeout
|
// Disconnect this client since he requested something that created a timeout
|
||||||
transportClient->killConnection("API call timeouted.");
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// If the server decided to kill the connection after the response, do it now
|
||||||
|
if (transportClient->killConnectionRequested()) {
|
||||||
|
transportClient->killConnection(transportClient->killConnectionReason());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -392,8 +392,11 @@ void TunnelProxyServer::onClientDataAvailable(const QUuid &clientId, const QByte
|
|||||||
TunnelProxyClientConnection *clientConnection = serverConnection->getClientConnection(frame.socketAddress);
|
TunnelProxyClientConnection *clientConnection = serverConnection->getClientConnection(frame.socketAddress);
|
||||||
if (!clientConnection) {
|
if (!clientConnection) {
|
||||||
qCWarning(dcTunnelProxyServer()) << "The server connection wants to send data to a client connection which has not been registered to the server.";
|
qCWarning(dcTunnelProxyServer()) << "The server connection wants to send data to a client connection which has not been registered to the server.";
|
||||||
// FIXME: tell the server this client does not exist
|
qCWarning(dcTunnelProxyServer()) << "Notifying the server that there is no longer any socket connected with address" << frame.socketAddress;
|
||||||
return;
|
QVariantMap params;
|
||||||
|
params.insert("socketAddress", frame.socketAddress);
|
||||||
|
m_jsonRpcServer->sendNotification("TunnelProxy", "ClientDisconnected", params, serverConnection->transportClient());
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
qCDebug(dcTunnelProxyServerTraffic()) << "--> Tunnel data from server socket" << frame.socketAddress << "to" << clientConnection << "\n" << frame.data;
|
qCDebug(dcTunnelProxyServerTraffic()) << "--> Tunnel data from server socket" << frame.socketAddress << "to" << clientConnection << "\n" << frame.data;
|
||||||
|
|||||||
Reference in New Issue
Block a user