feat: Add Recon State read to ReconManager

This commit is contained in:
chenhuijun
2024-05-27 13:36:07 +08:00
parent 8bba77cd86
commit 03bf58f069
2 changed files with 7 additions and 1 deletions

View File

@@ -39,7 +39,7 @@ RequestResult ReconClient::CheckActive()
auto resp = mRequest.post(mHost + STATE_URL, content, mHeaders); auto resp = mRequest.post(mHost + STATE_URL, content, mHeaders);
if (resp.httpCode() == 200) if (resp.httpCode() == 200)
{ {
return RequestResult::Success(); return RequestResult::Success(resp.getContent());
} }
else else
{ {

View File

@@ -4,6 +4,7 @@
#include <QTimer> #include <QTimer>
#include "QDebug" #include "QDebug"
#include "json/cJSON.h"
namespace namespace
{ {
@@ -100,6 +101,11 @@ void ReconManager::queryReconStatus(const QStringList& aScanIDs)
void ReconManager::checkReconConnection() void ReconManager::checkReconConnection()
{ {
auto response = mReconClient->CheckActive(); auto response = mReconClient->CheckActive();
cJSON* json = cJSON_Parse(response.message().data());
cJSON* stateProperty = cJSON_GetObjectItem(json, "State");
int state = stateProperty->valueint;
cJSON_Delete(json);
qDebug()<<"Recon State:"<<state;
if(mIsConnected != response.good()) if(mIsConnected != response.good())
{ {
emit checkReconConnectionResponsed(response.good()); emit checkReconConnectionResponsed(response.good());