fix an issue where it might happen that a notification breaks a reply
This commit is contained in:
parent
e06ff3ca01
commit
2cf07bcc35
@ -397,6 +397,22 @@ void JsonRpcClient::dataReceived(const QByteArray &data)
|
||||
getCloudConnectionStatus();
|
||||
}
|
||||
|
||||
// check if this is a notification
|
||||
if (dataMap.contains("notification")) {
|
||||
QStringList notification = dataMap.value("notification").toString().split(".");
|
||||
QString nameSpace = notification.first();
|
||||
JsonHandler *handler = m_notificationHandlers.value(nameSpace).first;
|
||||
|
||||
if (!handler) {
|
||||
// qWarning() << "JsonRpc: handler not implemented:" << nameSpace;
|
||||
return;
|
||||
}
|
||||
|
||||
// qDebug() << "Incoming notification:" << jsonDoc.toJson();
|
||||
QMetaObject::invokeMethod(handler, m_notificationHandlers.value(nameSpace).second.toLatin1().data(), Q_ARG(QVariantMap, dataMap));
|
||||
return;
|
||||
}
|
||||
|
||||
// check if this is a reply to a request
|
||||
int commandId = dataMap.value("id").toInt();
|
||||
JsonRpcReply *reply = m_replies.take(commandId);
|
||||
@ -422,21 +438,6 @@ void JsonRpcClient::dataReceived(const QByteArray &data)
|
||||
emit responseReceived(reply->commandId(), dataMap.value("params").toMap());
|
||||
return;
|
||||
}
|
||||
|
||||
// check if this is a notification
|
||||
if (dataMap.contains("notification")) {
|
||||
QStringList notification = dataMap.value("notification").toString().split(".");
|
||||
QString nameSpace = notification.first();
|
||||
JsonHandler *handler = m_notificationHandlers.value(nameSpace).first;
|
||||
|
||||
if (!handler) {
|
||||
// qWarning() << "JsonRpc: handler not implemented:" << nameSpace;
|
||||
return;
|
||||
}
|
||||
|
||||
// qDebug() << "Incoming notification:" << jsonDoc.toJson();
|
||||
QMetaObject::invokeMethod(handler, m_notificationHandlers.value(nameSpace).second.toLatin1().data(), Q_ARG(QVariantMap, dataMap));
|
||||
}
|
||||
}
|
||||
|
||||
JsonRpcReply::JsonRpcReply(int commandId, QString nameSpace, QString method, QVariantMap params, QPointer<QObject> caller, const QString &callback):
|
||||
|
||||
Reference in New Issue
Block a user