diff --git a/client/client.cpp b/client/client.cpp index 1c9354d..f9e9c93 100644 --- a/client/client.cpp +++ b/client/client.cpp @@ -71,23 +71,27 @@ void CClient::run(const std::string& ip, const std::string& port) while (1) { char* readline = fc_readline(); - if (!th_run_) { + if (readline == nullptr) { + break; + } + if (!th_run_ || !client_->is_normal()) { + logger_->warn("The link has been closed and cannot be continued. It will automatically exit."); break; } std::string cmd_input(readline); fc_free(readline); std::cout << "" << std::endl; cmd_input = ofen::COfStr::trim(cmd_input); - if (cmd_input == "end") { + if (cmd_input == "end" || cmd_input == "End") { th_run_ = false; std::this_thread::sleep_for(std::chrono::milliseconds(10)); break; } - if (cmd_input == "Get") { + if (cmd_input == "Get" || cmd_input == "get") { get_task_list(); continue; } - if (cmd_input == "Cancel") { + if (cmd_input == "Cancel" || cmd_input == "cancel") { cancel_task(); continue; } @@ -100,15 +104,15 @@ void CClient::run(const std::string& ip, const std::string& port) std::string scmd = param.substr(0, param.find_first_of(" ")); param.erase(0, param.find_first_of(" ") + 1); - if (scmd == "Update") { + if (scmd == "Update" || scmd == "update") { request_update_list(param); continue; } - if (scmd == "Down") { + if (scmd == "Down" || scmd == "down") { down_task(param); continue; } - if (scmd == "Up") { + if (scmd == "Up" || scmd == "up") { up_task(param); continue; } diff --git a/filecomplete b/filecomplete index 51baea9..569ba72 160000 --- a/filecomplete +++ b/filecomplete @@ -1 +1 @@ -Subproject commit 51baea993f2d77f5973d1c57f05557c6bbd71695 +Subproject commit 569ba7232d12573bff572d71043a5fd0e03f9df0 diff --git a/net/net_base.cpp b/net/net_base.cpp index c2a6f0a..70074af 100644 --- a/net/net_base.cpp +++ b/net/net_base.cpp @@ -90,3 +90,8 @@ void CTcpClient::async_recv() } }); } + +bool CTcpClient::is_normal() +{ + return is_normal_; +} diff --git a/net/net_base.h b/net/net_base.h index afecc4d..9d262cc 100644 --- a/net/net_base.h +++ b/net/net_base.h @@ -18,6 +18,7 @@ public: bool send(const char* data, int len); void register_func(ExFun_t&& f); void async_recv(); + bool is_normal(); private: std::shared_ptr logger_;