Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
This commit is contained in:
stephb9959
2022-06-22 11:52:50 -07:00
parent 3d252116dd
commit 4b6880a306
6 changed files with 168 additions and 80 deletions

View File

@@ -23,7 +23,9 @@ namespace OpenWifi::RESTAPI_RPC {
if (StorageService()->AddCommand(Cmd.SerialNumber, Cmd, Status)) {
Poco::JSON::Object RetObj;
Cmd.to_json(RetObj);
return Handler->ReturnObject(RetObj);
if(Handler!= nullptr)
return Handler->ReturnObject(RetObj);
return;
}
return Handler->ReturnStatus(Poco::Net::HTTPResponse::HTTP_INTERNAL_SERVER_ERROR);
}
@@ -114,17 +116,23 @@ namespace OpenWifi::RESTAPI_RPC {
Logger.information( fmt::format("Command({}): completed in {:.3f}ms.", Cmd.UUID, Cmd.executionTime));
return;
} else {
SetCommandStatus(Cmd, Request, Response, Handler,
Storage::COMMAND_FAILED, Logger);
Logger.information(fmt::format(
"Invalid response for command '{}'. Missing status.", Cmd.UUID));
Cmd.executionTime = rpc_execution_time.count();
if(Cmd.Command=="ping") {
SetCommandStatus(Cmd, Request, Response, Handler, Storage::COMMAND_COMPLETED, Logger);
Logger.information(fmt::format(
"Invalid response for command '{}'. Missing status.", Cmd.UUID));
} else {
SetCommandStatus(Cmd, Request, Response, Handler, Storage::COMMAND_FAILED, Logger);
Logger.information(fmt::format(
"Invalid response for command '{}'. Missing status.", Cmd.UUID));
}
return;
}
} else {
SetCommandStatus(Cmd, Request, Response, Handler, Storage::COMMAND_FAILED,
Logger);
Logger.information(fmt::format(
"Invalid response for command '{}'. Missing status.", Cmd.UUID));
"Invalid response for command '{}'. Missing result.", Cmd.UUID));
return;
}
} else if (rpc_result == std::future_status::timeout) {