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

Method AgentClient

source/MaaAgentClient/Client/AgentClient.cpp:16–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14#include "MaaUtils/Uuid.h"
15
16MAA_AGENT_CLIENT_NS_BEGIN
17
18AgentClient::AgentClient(const std::string& identifier)
19{
20 LogFunc;
21
22 if (auto port_opt = parse_tcp_port(identifier)) {
23 LogInfo << "Using TCP mode" << VAR(*port_opt);
24 uint16_t port = init_tcp_socket(*port_opt, true);
25 identifier_ = std::to_string(port);
26 }
27 // Windows 上检测 IPC 是否可能失败,如果失败则自动使用 TCP
28 else if (should_fallback_to_tcp()) {
29 LogInfo << "IPC may fail on this system, using TCP instead";
30 uint16_t port = init_tcp_socket(0, true);
31 identifier_ = std::to_string(port);
32 }
33 else {
34 identifier_ = identifier.empty() ? make_uuid() : identifier;
35 init_socket(identifier_, true);
36 }
37
38 LogInfo << VAR(identifier) << VAR(identifier_);
39}
40
41AgentClient::~AgentClient()
42{

Callers

nothing calls this directly

Calls 1

emptyMethod · 0.45

Tested by

no test coverage detected