QJsonRpcSocket::sendMessageBlocking

Issue #30 new
Андрей Сидоренко created an issue

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();

}

Comments (0)

  1. Log in to comment