From 03bf58f069b2c67b0540ba6988fe7a5afd949a89 Mon Sep 17 00:00:00 2001 From: chenhuijun Date: Mon, 27 May 2024 13:36:07 +0800 Subject: [PATCH] feat: Add Recon State read to ReconManager --- src/recon/ReconClient.cpp | 2 +- src/recon/ReconManager.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/recon/ReconClient.cpp b/src/recon/ReconClient.cpp index 381fde4..c67c8a7 100644 --- a/src/recon/ReconClient.cpp +++ b/src/recon/ReconClient.cpp @@ -39,7 +39,7 @@ RequestResult ReconClient::CheckActive() auto resp = mRequest.post(mHost + STATE_URL, content, mHeaders); if (resp.httpCode() == 200) { - return RequestResult::Success(); + return RequestResult::Success(resp.getContent()); } else { diff --git a/src/recon/ReconManager.cpp b/src/recon/ReconManager.cpp index 75cc71f..b9e234e 100644 --- a/src/recon/ReconManager.cpp +++ b/src/recon/ReconManager.cpp @@ -4,6 +4,7 @@ #include #include "QDebug" +#include "json/cJSON.h" namespace { @@ -100,6 +101,11 @@ void ReconManager::queryReconStatus(const QStringList& aScanIDs) void ReconManager::checkReconConnection() { 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:"<