From 8dc6184348b58b47443e04db6e5adeb3b8b5d029 Mon Sep 17 00:00:00 2001 From: taynpg Date: Thu, 19 Dec 2024 09:50:29 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E6=AD=A3=E9=80=80?= =?UTF-8?q?=E5=87=BA=E6=97=B6=E5=85=B3=E9=97=AD=E5=8F=91=E9=80=81=E5=BF=83?= =?UTF-8?q?=E8=B7=B3=E5=8C=85=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/client.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/client.cpp b/client/client.cpp index d1c86e6..af5c1a7 100644 --- a/client/client.cpp +++ b/client/client.cpp @@ -60,6 +60,8 @@ void CClient::run(const std::string& ip, const std::string& port) std::string cmd_input(line); if (cmd_input == "end") { + th_run_ = false; + std::this_thread::sleep_for(std::chrono::milliseconds(10)); break; } auto vec = COfStr::split(cmd_input, " "); @@ -440,7 +442,7 @@ void CClient::hearts() buf->type_ = TYPE_HEARTS; while (th_run_) { sleep_.sleep(); - if (!send_frame(buf.get())) { + if (th_run_ && !send_frame(buf.get())) { logger_->error("{} send failed.", __FUNCTION__); th_run_ = false; }