MCPcopy Create free account
hub / github.com/audacity/audacity / AcknowledgeTask

Method AcknowledgeTask

libraries/lib-cloud-audiocom/TaskExecutionService.cpp:290–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

288}
289
290bool TaskExecutionService::AcknowledgeTask(const std::string& taskId)
291{
292 using namespace audacity::network_manager;
293 using namespace rapidjson;
294
295 try
296 {
297 auto& serviceConfig = GetServiceConfig();
298 auto& oauthService = GetOAuthService();
299
300 if (!oauthService.HasAccessToken())
301 return false;
302
303 StringBuffer buffer;
304
305 Request request(serviceConfig.GetTaskAckUrl(taskId));
306
307 request.setHeader(
308 common_headers::ContentType, common_content_types::ApplicationJson);
309 request.setHeader(
310 common_headers::Accept, common_content_types::ApplicationJson);
311
312 SetCommonHeaders(request);
313 SetOptionalHeaders(request);
314
315 auto response = NetworkManager::GetInstance().doPost(
316 request, buffer.GetString(), buffer.GetSize());
317
318 const int maxWaitSeconds = 10;
319 for (int i = 0; i < maxWaitSeconds && !response->isFinished() && !mStopRequested; ++i)
320 {
321 std::this_thread::sleep_for(std::chrono::seconds(1));
322 }
323
324 if (!response->isFinished())
325 {
326 response->abort();
327 return false;
328 }
329
330 int httpCode = response->getHTTPCode();
331 return httpCode >= 200 && httpCode < 300;
332 }
333 catch (...)
334 {
335 return false;
336 }
337}
338
339void TaskExecutionService::SendResult(
340 const std::string& taskId, sync::TaskStatus status,

Callers

nothing calls this directly

Calls 11

SetCommonHeadersFunction · 0.85
SetOptionalHeadersFunction · 0.85
HasAccessTokenMethod · 0.80
GetTaskAckUrlMethod · 0.80
setHeaderMethod · 0.80
doPostMethod · 0.80
GetStringMethod · 0.45
GetSizeMethod · 0.45
isFinishedMethod · 0.45
abortMethod · 0.45
getHTTPCodeMethod · 0.45

Tested by

no test coverage detected