From 7799407a670a245f7f1ec18b5bbbee2accb5b224 Mon Sep 17 00:00:00 2001 From: cxh Date: Thu, 19 Mar 2026 10:14:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=BC=96=E8=AF=91=E4=BE=9D?= =?UTF-8?q?=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 7 ++++--- include/tunnel_client.hpp | 12 +++++------- src/tunnel_client.cpp | 8 ++++---- third_party/asio | 1 + 4 files changed, 14 insertions(+), 14 deletions(-) create mode 160000 third_party/asio diff --git a/CMakeLists.txt b/CMakeLists.txt index 7adc6c5..e9a5776 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,7 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) add_compile_definitions(GLIB_DISABLE_DEPRECATION_WARNINGS) +add_compile_definitions(ASIO_STANDALONE) # 输出目录 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin) @@ -23,12 +24,12 @@ pkg_check_modules(GSTREAMER REQUIRED gstreamer-1.0) # include 路径 include_directories( - ${CMAKE_SOURCE_DIR}/third_party/include/websocketpp ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/third_party/include ${CMAKE_SOURCE_DIR}/third_party/include/paho_mqtt + ${CMAKE_SOURCE_DIR}/third_party/asio/include ${GSTREAMER_INCLUDE_DIRS} - /usr/include + /usr/include ) # 源文件 @@ -52,4 +53,4 @@ target_link_libraries(${APP_NAME} ${CMAKE_SOURCE_DIR}/third_party/lib/libpaho-mqttpp3.a ${CMAKE_SOURCE_DIR}/third_party/lib/libpaho-mqtt3a.a ${CMAKE_SOURCE_DIR}/third_party/lib/libpaho-mqtt3c.a -) +) \ No newline at end of file diff --git a/include/tunnel_client.hpp b/include/tunnel_client.hpp index 233f84c..79bf93b 100644 --- a/include/tunnel_client.hpp +++ b/include/tunnel_client.hpp @@ -1,5 +1,9 @@ #pragma once +#ifndef ASIO_STANDALONE +#define ASIO_STANDALONE +#endif + #include #include #include @@ -7,7 +11,6 @@ #include #include -// websocketpp 客户端类型 using ws_client = websocketpp::client; class TunnelClient @@ -20,11 +23,7 @@ class TunnelClient private: void run_loop(); - - // 处理 Server 的 JSON 请求(GET / POST / 大文件流) void handle_request_and_reply(const nlohmann::json& req); - - // 线程安全发送函数 void send_text_safe(const std::string& s); void send_binary_safe(const void* data, size_t len); @@ -36,7 +35,6 @@ class TunnelClient std::atomic running_{false}; std::thread th_; - // websocketpp ws_client* client_ = nullptr; websocketpp::connection_hdl hdl_; -}; +}; \ No newline at end of file diff --git a/src/tunnel_client.cpp b/src/tunnel_client.cpp index 5586a7e..32b3382 100644 --- a/src/tunnel_client.cpp +++ b/src/tunnel_client.cpp @@ -1,3 +1,7 @@ +#ifndef ASIO_STANDALONE +#define ASIO_STANDALONE +#endif + #include "tunnel_client.hpp" #include @@ -8,14 +12,11 @@ #include #include #include -#include -#include #include "httplib.h" #include "logger.hpp" using json = nlohmann::json; -using ws_client = websocketpp::client; namespace { @@ -30,7 +31,6 @@ static bool looks_binary_content_type(const std::string& ct) return false; } -// 小工具:拼 log 字符串 static inline std::string kv(const std::string& k, const std::string& v) { return k + "=" + v; } static inline std::string kv(const std::string& k, int v) { return k + "=" + std::to_string(v); } diff --git a/third_party/asio b/third_party/asio new file mode 160000 index 0000000..bd500f0 --- /dev/null +++ b/third_party/asio @@ -0,0 +1 @@ +Subproject commit bd500f0a018db9a845ebaaed5c0318343ae9f497