Tell the server if a client has been disconnected without notice
parent
19e85d509e
commit
eb609da9a4
|
|
@ -244,7 +244,7 @@ void JsonRpcServer::processDataPacket(TransportClient *transportClient, const QB
|
|||
}
|
||||
|
||||
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) {
|
||||
m_asyncReplies.insert(reply, transportClient);
|
||||
reply->setClientId(transportClient->clientId());
|
||||
|
|
@ -297,25 +297,26 @@ void JsonRpcServer::asyncReplyFinished()
|
|||
qCWarning(dcJsonRpc()) << "Return value validation failed. This should never happen. Please check the source code.";
|
||||
}
|
||||
|
||||
sendResponse(transportClient, reply->commandId(), reply->data());
|
||||
|
||||
if (!reply->success()) {
|
||||
// Disconnect this client since the request was not successfully
|
||||
transportClient->killConnectionAfterResponse("API call was not successfully.");
|
||||
}
|
||||
|
||||
sendResponse(transportClient, reply->commandId(), reply->data());
|
||||
|
||||
} else {
|
||||
qCWarning(dcJsonRpc()) << "The reply timeouted.";
|
||||
transportClient->killConnectionAfterResponse("API call timeouted.");
|
||||
sendErrorResponse(transportClient, reply->commandId(), "Command timed out");
|
||||
// Disconnect this client since he requested something that created a timeout
|
||||
|
||||
}
|
||||
|
||||
|
||||
// If the server decided to kill the connection after the response, do it now
|
||||
if (transportClient->killConnectionRequested()) {
|
||||
transportClient->killConnection(transportClient->killConnectionReason());
|
||||
}
|
||||
|
||||
} else {
|
||||
qCWarning(dcJsonRpc()) << "The reply timeouted.";
|
||||
sendErrorResponse(transportClient, reply->commandId(), "Command timed out");
|
||||
// Disconnect this client since he requested something that created a timeout
|
||||
transportClient->killConnection("API call timeouted.");
|
||||
}
|
||||
}
|
||||
|
||||
void JsonRpcServer::registerClient(TransportClient *transportClient)
|
||||
|
|
|
|||
|
|
@ -392,8 +392,11 @@ void TunnelProxyServer::onClientDataAvailable(const QUuid &clientId, const QByte
|
|||
TunnelProxyClientConnection *clientConnection = serverConnection->getClientConnection(frame.socketAddress);
|
||||
if (!clientConnection) {
|
||||
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
|
||||
return;
|
||||
qCWarning(dcTunnelProxyServer()) << "Notifying the server that there is no longer any socket connected with address" << frame.socketAddress;
|
||||
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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue