更新编译依赖

This commit is contained in:
cxh 2026-03-19 10:14:40 +08:00
parent 141f5b5b13
commit 7799407a67
4 changed files with 14 additions and 14 deletions

View File

@ -13,6 +13,7 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_compile_definitions(GLIB_DISABLE_DEPRECATION_WARNINGS) add_compile_definitions(GLIB_DISABLE_DEPRECATION_WARNINGS)
add_compile_definitions(ASIO_STANDALONE)
# #
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin)
@ -23,12 +24,12 @@ pkg_check_modules(GSTREAMER REQUIRED gstreamer-1.0)
# include # include
include_directories( include_directories(
${CMAKE_SOURCE_DIR}/third_party/include/websocketpp
${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/third_party/include ${CMAKE_SOURCE_DIR}/third_party/include
${CMAKE_SOURCE_DIR}/third_party/include/paho_mqtt ${CMAKE_SOURCE_DIR}/third_party/include/paho_mqtt
${CMAKE_SOURCE_DIR}/third_party/asio/include
${GSTREAMER_INCLUDE_DIRS} ${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-mqttpp3.a
${CMAKE_SOURCE_DIR}/third_party/lib/libpaho-mqtt3a.a ${CMAKE_SOURCE_DIR}/third_party/lib/libpaho-mqtt3a.a
${CMAKE_SOURCE_DIR}/third_party/lib/libpaho-mqtt3c.a ${CMAKE_SOURCE_DIR}/third_party/lib/libpaho-mqtt3c.a
) )

View File

@ -1,5 +1,9 @@
#pragma once #pragma once
#ifndef ASIO_STANDALONE
#define ASIO_STANDALONE
#endif
#include <atomic> #include <atomic>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <string> #include <string>
@ -7,7 +11,6 @@
#include <websocketpp/client.hpp> #include <websocketpp/client.hpp>
#include <websocketpp/config/asio_no_tls_client.hpp> #include <websocketpp/config/asio_no_tls_client.hpp>
// websocketpp 客户端类型
using ws_client = websocketpp::client<websocketpp::config::asio_client>; using ws_client = websocketpp::client<websocketpp::config::asio_client>;
class TunnelClient class TunnelClient
@ -20,11 +23,7 @@ class TunnelClient
private: private:
void run_loop(); void run_loop();
// 处理 Server 的 JSON 请求GET / POST / 大文件流)
void handle_request_and_reply(const nlohmann::json& req); void handle_request_and_reply(const nlohmann::json& req);
// 线程安全发送函数
void send_text_safe(const std::string& s); void send_text_safe(const std::string& s);
void send_binary_safe(const void* data, size_t len); void send_binary_safe(const void* data, size_t len);
@ -36,7 +35,6 @@ class TunnelClient
std::atomic<bool> running_{false}; std::atomic<bool> running_{false};
std::thread th_; std::thread th_;
// websocketpp
ws_client* client_ = nullptr; ws_client* client_ = nullptr;
websocketpp::connection_hdl hdl_; websocketpp::connection_hdl hdl_;
}; };

View File

@ -1,3 +1,7 @@
#ifndef ASIO_STANDALONE
#define ASIO_STANDALONE
#endif
#include "tunnel_client.hpp" #include "tunnel_client.hpp"
#include <atomic> #include <atomic>
@ -8,14 +12,11 @@
#include <string> #include <string>
#include <thread> #include <thread>
#include <vector> #include <vector>
#include <websocketpp/client.hpp>
#include <websocketpp/config/asio_no_tls_client.hpp>
#include "httplib.h" #include "httplib.h"
#include "logger.hpp" #include "logger.hpp"
using json = nlohmann::json; using json = nlohmann::json;
using ws_client = websocketpp::client<websocketpp::config::asio_client>;
namespace namespace
{ {
@ -30,7 +31,6 @@ static bool looks_binary_content_type(const std::string& ct)
return false; 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, const std::string& v) { return k + "=" + v; }
static inline std::string kv(const std::string& k, int v) { return k + "=" + std::to_string(v); } static inline std::string kv(const std::string& k, int v) { return k + "=" + std::to_string(v); }

1
third_party/asio vendored Submodule

@ -0,0 +1 @@
Subproject commit bd500f0a018db9a845ebaaed5c0318343ae9f497