MCPcopy Create free account
hub / github.com/MaaXYZ/MaaFramework / action_agent

Method action_agent

source/MaaAgentClient/Client/AgentClient.cpp:2570–2613  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2568}
2569
2570MaaBool AgentClient::action_agent(
2571 MaaContext* context,
2572 MaaTaskId task_id,
2573 const char* node_name,
2574 const char* custom_action_name,
2575 const char* custom_action_param,
2576 MaaRecoId reco_id,
2577 const MaaRect* box,
2578 void* trans_arg)
2579{
2580 LogTrace << VAR_VOIDP(context) << VAR(task_id) << VAR(node_name) << VAR(custom_action_name) << VAR(custom_action_param);
2581
2582 if (!trans_arg) {
2583 LogError << "trans_arg is null";
2584 return false;
2585 }
2586
2587 AgentClient* pthis = reinterpret_cast<AgentClient*>(trans_arg);
2588 if (!pthis) {
2589 LogError << "pthis is null";
2590 return false;
2591 }
2592
2593 CustomActionRequest req {
2594 .context_id = pthis->context_id(context),
2595 .task_id = task_id,
2596 .node_name = node_name,
2597 .custom_action_name = custom_action_name,
2598 .custom_action_param = custom_action_param,
2599 .reco_id = reco_id,
2600 .box = box ? std::array<int32_t, 4> { box->x, box->y, box->width, box->height } : std::array<int32_t, 4> { },
2601 };
2602
2603 auto resp_opt = pthis->send_and_recv<CustomActionResponse>(req);
2604 if (!resp_opt) {
2605 LogError << "failed to send_and_recv" << VAR(req);
2606 return false;
2607 }
2608
2609 const CustomActionResponse& resp = *resp_opt;
2610 LogTrace << VAR(resp);
2611
2612 return resp.ret;
2613}
2614
2615std::string AgentClient::context_id(MaaContext* context)
2616{

Callers

nothing calls this directly

Calls 1

context_idMethod · 0.80

Tested by

no test coverage detected