QJsonRpcSocket::sendMessageBlocking
Issue #30
new
I think it will be usefull. add connect(this, SIGNAL(destroyed()), &responseLoop, SLOT(quit()));
//qjsonrpcsocket.cpp QJsonRpcMessage QJsonRpcSocket::sendMessageBlocking(const QJsonRpcMessage &message, int msecs) { Q_D(QJsonRpcSocket); QJsonRpcServiceReply *reply = sendMessage(message); QScopedPointer<QJsonRpcServiceReply> replyPtr(reply);
QEventLoop responseLoop;
connect(reply, SIGNAL(finished()), &responseLoop, SLOT(quit()));
connect(this, SIGNAL(destroyed()), &responseLoop, SLOT(quit()));
QTimer::singleShot(msecs, &responseLoop, SLOT(quit()));
responseLoop.exec();
if (!reply->response().isValid()) {
d->replies.remove(message.id());
return message.createErrorResponse(QJsonRpc::TimeoutError, "request timed out");
}
return reply->response();
}