pollDelegator static method
Implementation
static Future<JsonResponse> pollDelegator() async {
try {
HttpResponse res =
await HttpRequests.get(ArgusAgentShared.DELEGATOR_ROOT);
if (res.isRedirect) {
throw HttpRequestException(
code: "DisallowedPathway",
message: "Expected Raw, found Redirect");
}
if (res.json.isNotEmpty) {
return JsonResponse.good(
value: res.json, reason: _superagent_received_res);
} else {
throw HttpRequestException(
code: "UnexpectedEmptyJsonBody",
message: "The length of the body is empty?");
}
} on HttpRequestException catch (e) {
Debug().watchdog(
"[ARGUS_SUPERAGENT] failed to ret ${ArgusAgentShared.DELEGATOR_ROOT} with ${e.code}");
return JsonResponse.fuckedUp(
reason: "Failed to retrieve [Error Code: ${e.code}]");
}
}