From 806485dc90b5dee22d4c5c95f4901d9f0bf1df48 Mon Sep 17 00:00:00 2001 From: taynpg Date: Mon, 13 Jan 2025 16:24:08 +0800 Subject: [PATCH] =?UTF-8?q?add=EF=BC=9A1.=E9=9D=9E=E6=AD=A3=E5=B8=B8?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=97=B6=E7=BB=A7=E7=BB=AD=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E4=BC=9A=E8=87=AA=E5=8A=A8=E9=80=80=E5=87=BA=E3=80=822.?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E7=8E=B0=E5=9C=A8=E4=B8=8D=E5=8C=BA=E5=88=86?= =?UTF-8?q?=E9=A6=96=E5=AD=97=E6=AF=8D=E5=A4=A7=E5=86=99=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/client.cpp | 18 +++++++++++------- filecomplete | 2 +- net/net_base.cpp | 5 +++++ net/net_base.h | 1 + 4 files changed, 18 insertions(+), 8 deletions(-) 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_;