This commit is contained in:
gjm committed 2026-09-28 22:13:47 +08:00
1 parent 5289689737
commit 1fdcdefef1
3 files changed
+36 -4

No files matched your search

+1 -1
View File
@@ -86,7 +86,7 @@ endforeach()
if(MSVC) if(MSVC)
# 🌟 开启 MSVC 多核并发编译!巨型工程提速的终极神器 # 🌟 开启 MSVC 多核并发编译!巨型工程提速的终极神器
add_compile_options(/MP) add_compile_options(/MP)
# 🌟 统一设置全局 Unicode 宏 (ARX 和 MFC 都强烈需要) # 🌟 统一设置全局 Unicode 宏 (ARX 和 MFC 都强烈需要)
add_compile_definitions( add_compile_definitions(
UNICODE UNICODE
+15 -3
View File
@@ -131,10 +131,21 @@ namespace mcp
bool init_mcp() bool init_mcp()
{ {
g_bRunning = true; g_bRunning = true;
g_serverThread = std::thread(TcpServerLoop); try
acutPrintf(_T("\n[MCP Server] 后台 TCP 监听线程已启动 (端口: 8080)...\n")); {
g_serverThread = std::thread(TcpServerLoop);
acutPrintf(_T("\n[MCP Server] 后台 TCP 监听线程已启动 (端口: 8080)...\n"));
}
catch (const std::system_error &e)
{
// 线程创建失败,重置状态标志并输出错误
g_bRunning = false;
// e.what() 返回的是 const char*,所以在 acutPrintf 中要用 %hs 而不是 %s 或 %ls
acutPrintf(_T("\n[MCP Server] 致命错误:无法创建后台监听线程!原因: %hs\n"), e.what());
}
return g_bRunning;
} }
bool close_mcp() bool close_mcp()
{ {
g_bRunning = false; g_bRunning = false;
@@ -143,5 +154,6 @@ namespace mcp
g_serverThread.join(); g_serverThread.join();
} }
acutPrintf(_T("\n[MCP Server] 插件已卸载,线程已关闭。\n")); acutPrintf(_T("\n[MCP Server] 插件已卸载,线程已关闭。\n"));
return true;
} }
} }
+20
View File
@@ -0,0 +1,20 @@
import socket
import json
# 模拟大模型生成的 JSON 指令
command = {
"cmd": "draw_circle",
"x": 500.0,
"y": 500.0,
"r": 250.0
}
try:
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect(("127.0.0.1", 8080))
# 发送序列化后的 JSON 字符串
client.sendall(json.dumps(command).encode('utf-8'))
client.close()
print("指令发送成功,请查看 AutoCAD 屏幕。")
except Exception as e:
print(f"连接失败: {e}")