feat: add recon message receive and popup function
This commit is contained in:
@@ -35,4 +35,11 @@ struct MPPSSetting
|
||||
};
|
||||
|
||||
|
||||
struct ServerSideMessage
|
||||
{
|
||||
int ErrorCode = 0;
|
||||
std::string MessageContent;
|
||||
std::string MessageUUID;
|
||||
};
|
||||
|
||||
#endif // __SCAN_H__
|
||||
@@ -3,6 +3,11 @@
|
||||
#include "json/jsonobject.h"
|
||||
#include "log/LogManager.h"
|
||||
|
||||
#include "event/EventCenter.h"
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonValue>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QTimer>
|
||||
#include "QDebug"
|
||||
#include "json/cJSON.h"
|
||||
@@ -132,11 +137,26 @@ void ReconManager::checkReconConnection()
|
||||
int state = 0;
|
||||
if (mIsConnected)
|
||||
{
|
||||
cJSON* json = cJSON_Parse(response.message().data());
|
||||
cJSON* stateProperty = cJSON_GetObjectItem(json, "State");
|
||||
state = stateProperty->valueint;
|
||||
cJSON_Delete(json);
|
||||
qDebug()<<"Recon State:"<<state;
|
||||
QJsonObject messageState = QJsonDocument::fromJson(response.message().data()).object();
|
||||
|
||||
state = messageState["state"].toInt();
|
||||
emit reconStateResponsed(mIsConnected, state);
|
||||
if (!messageState["messages"].isArray())
|
||||
{
|
||||
qDebug()<<"messages:"<<messageState["messages"].toString();
|
||||
|
||||
}
|
||||
QJsonArray messages = messageState["messages"].toArray();
|
||||
|
||||
for(auto item : messages)
|
||||
{
|
||||
struct ServerSideMessage value;
|
||||
QJsonObject obj = item.toObject();
|
||||
value.ErrorCode = obj["errorCode"].toInt();
|
||||
QString str = obj["messageContent"].toString();
|
||||
emit reconMessagereceived(str);
|
||||
}
|
||||
return;
|
||||
}
|
||||
emit reconStateResponsed(mIsConnected, state);
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ signals:
|
||||
void checkReconConnectionResponsed(bool aResult);
|
||||
void getReconVersionResponsed(const QString& aResult);
|
||||
void reconStateResponsed(bool aIsConnected, int aState);
|
||||
void reconMessagereceived(const QString& aMessage);
|
||||
|
||||
private:
|
||||
ReconClient* mReconClient;
|
||||
|
||||
Reference in New Issue
Block a user