#pragma once #include #include #include #include #include #include using ws_client = websocketpp::client; class TunnelClient { public: TunnelClient(const std::string& vid, const std::string& server_ws_url, int local_http_port); void start(); void stop(); private: void run_loop(); 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); private: std::string vid_; std::string ws_url_; int local_port_ = 0; std::atomic running_{false}; std::thread th_; ws_client* client_ = nullptr; websocketpp::connection_hdl hdl_; };