mrDarker
2025-07-16 1dbe46cd9d0f181d08d5a69f72d8548628a13b9d
EdgeInspector_App/WebSocket/WebSocketClient.h
@@ -1,4 +1,4 @@
#ifndef WEBSOCKETCLIENT_H
#ifndef WEBSOCKETCLIENT_H
#define WEBSOCKETCLIENT_H
//#include <websocketpp/config/asio_no_tls_client.hpp>
@@ -27,62 +27,62 @@
//    WebSocketClient();
//    ~WebSocketClient();
//
//    // 连接到指定的URI
//    // 连接到指定的URI
//    void connect(const std::string& uri);
//
//    // 增加客户端的状态标识
//    // 增加客户端的状态标识
//    bool is_busy() const;
//    void set_busy(bool busy);
//
//    // 发送文本消息
//    // 发送文本消息
//    void send(const std::string& message);
//
//    // 发送二进制数据
//    // 发送二进制数据
//    void send_binary(const std::vector<char>& binary_data);
//
//   // 通过队列发送文本消息
//   // 通过队列发送文本消息
//    void enqueue_message(const std::string& message);
//
//   // 通过队列发送二进制数据
//   // 通过队列发送二进制数据
//    void enqueue_binary(const std::vector<char>& binary_data);
//
//   // 处理下一个消息
//   // 处理下一个消息
//    void process_next_message();
//    void process_next_binary();
//
//   // 发送文本消息并等待回复
//   // 发送文本消息并等待回复
//    bool send_and_wait(const std::string& message, int timeout_ms);
//
//   // 发送二进制数据并等待回复
//   // 发送二进制数据并等待回复
//    bool send_binary_and_wait(const std::vector<char>& binary_data, int timeout_ms);
//
//    // 关闭连接
//    // 关闭连接
//    void close();
//
//    // 设置各种回调函数
//    // 设置各种回调函数
//    void set_open_handler(OpenHandler handler);
//    void set_message_handler(MessageHandler handler);
//    void set_close_handler(CloseHandler handler);
//    void set_fail_handler(FailHandler handler);
//    void set_pong_handler(PongHandler handler);
//
//    // 设置心跳间隔(单位:秒)
//    // 设置心跳间隔(单位:秒)
//    void set_heartbeat_interval(int interval);
//
//    // 获取当前连接的URL
//    // 获取当前连接的URL
//    std::string get_current_url();
//
//    // 检查当前连接是否仍然有效
//    // 检查当前连接是否仍然有效
//    bool is_connected() const;
//
//private:
//    // WebSocket 运行函数
//    // WebSocket 运行函数
//    void run();
//
//    // 心跳检查函数
//    // 心跳检查函数
//    void heartbeat();
//
//    // 回调函数触发器
//    // 回调函数触发器
//    void on_open(websocketpp::connection_hdl hdl);
//    void on_message(connection_hdl hdl, message_ptr msg);
//    void on_close(websocketpp::connection_hdl hdl);
@@ -90,13 +90,13 @@
//    void on_pong(websocketpp::connection_hdl hdl, const std::string& payload);
//
//private:
//    // WebSocket客户端实例
//    // WebSocket客户端实例
//    client m_client;
//
//    // WebSocket 连接句柄
//    // WebSocket 连接句柄
//    connection_hdl m_hdl;
//
//    // 线程相关
//    // 线程相关
//    std::thread m_thread;
//    std::thread m_heartbeat_thread;
//    std::atomic<bool> m_connected;
@@ -104,21 +104,21 @@
//    int m_heartbeat_interval;
//    bool m_message_received;
//
//    // 发送队列
//    // 发送队列
//    std::queue<std::string> m_message_queue;
//    std::queue<std::vector<char>> m_binary_queue;
//
//    // 标识客户端是否忙碌
//    // 标识客户端是否忙碌
//    std::atomic<bool> m_busy; 
//
//    // 线程同步相关
//    // 线程同步相关
//    bool m_close_done;
//    std::condition_variable m_cv;
//
//    // 互斥锁,用于保护共享资源
//    // 互斥锁,用于保护共享资源
//    std::mutex m_mutex;
//
//    // 回调函数
//    // 回调函数
//    OpenHandler m_open_handler;
//    MessageHandler m_message_handler;
//    CloseHandler m_close_handler;