feat: add recon message receive and popup function
This commit is contained in:
@@ -210,6 +210,8 @@ void DeviceManager::initDevice()
|
||||
}
|
||||
});
|
||||
connect(ReconManager::getInstance(), &ReconManager::reconStateResponsed, UsctStateManager::getInstance(), &UsctStateManager::updateReconState);
|
||||
connect(ReconManager::getInstance(), &ReconManager::reconMessagereceived, this,&DeviceManager::processReconMessage);
|
||||
|
||||
connect(this, &DeviceManager::checkReconConnection, ReconManager::getInstance(), &ReconManager::checkReconConnection);
|
||||
connect(reconConnectionTimer, &QTimer::timeout, this, &DeviceManager::prepareCheckReconConnection);
|
||||
connect(this, &DeviceManager::createEmptyScanToRecon, ReconManager::getInstance(), &ReconManager::createEmptyScan);
|
||||
@@ -1427,6 +1429,12 @@ void DeviceManager::prepareCheckReconConnection()
|
||||
emit checkReconConnection();
|
||||
}
|
||||
|
||||
void DeviceManager::processReconMessage(const QString &aMessage)
|
||||
{
|
||||
QString msg=aMessage;
|
||||
EventCenter::Default()->triggerEvent(WarningMessageRaise, nullptr, (QObject*)&aMessage);
|
||||
}
|
||||
|
||||
void DeviceManager::processEmergencyButtonReset(const QString& aResponse)
|
||||
{
|
||||
QJsonObject jsonObj = toJsonObject(aResponse);
|
||||
|
||||
@@ -145,6 +145,8 @@ private slots:
|
||||
void startCreateReconRecord();
|
||||
void updateReconConnectionState(bool aIsConnected);
|
||||
void prepareCheckReconConnection();
|
||||
void processReconMessage(const QString& aMessage);
|
||||
|
||||
//GUI
|
||||
void scanTimeout();
|
||||
|
||||
|
||||
@@ -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