#pragma once #include #include #include #include #include #include "file_oper.h" #include using namespace ofen; struct DownClientInfo { std::vector files; std::string id; }; enum TransState { TRANS_FAILE, TRANS_ING, TRANS_REDAY, TRANS_DONE }; struct TransInfomation { std::string cur_remote_id_; std::string cur_remote_file_; std::string cur_file_; FILE* file_{}; TransState trans_state_{TRANS_FAILE}; }; class CClient { public: CClient(const std::shared_ptr& logger); ~CClient(); public: void run(); public: bool get_task_list(); bool down_task(const std::string& param); bool up_task(const std::string& cmd); bool cancel_task(); bool down_one_file(const std::string& id, const std::string& file); void cancel_trans_file(const std::string& key = ""); private: bool send_frame(CFrameBuffer* buf); private: void handle_frame(CFrameBuffer* buf); void send_file_data_th(); private: std::shared_ptr logger_; asio::io_context io_context_; std::shared_ptr client_; std::vector supported_; std::map> task_list_; std::shared_ptr down_; std::map> up_; std::mutex mutex_; std::shared_ptr send_pool_; std::string work_key_; };