add:1.非正常状态时继续操作会自动退出。2.命令现在不区分首字母大写。

This commit is contained in:
taynpg 2025-01-13 16:24:08 +08:00
parent 1e62a52ef7
commit 806485dc90
4 changed files with 18 additions and 8 deletions

View File

@ -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;
}

@ -1 +1 @@
Subproject commit 51baea993f2d77f5973d1c57f05557c6bbd71695
Subproject commit 569ba7232d12573bff572d71043a5fd0e03f9df0

View File

@ -90,3 +90,8 @@ void CTcpClient::async_recv()
}
});
}
bool CTcpClient::is_normal()
{
return is_normal_;
}

View File

@ -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<spdlog::logger> logger_;