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