From b0b6d78630779f127cd69c95a63dbf57ba5f33b6 Mon Sep 17 00:00:00 2001 From: Kieran Kihn <114803508+kierankihn@users.noreply.github.com> Date: Sat, 29 Nov 2025 18:47:33 +0800 Subject: [PATCH] feat(network): add `stop` method to `NetworkServer` - Implemented `stop` method in `NetworkServer` to close the acceptor and stop the IO context. - Updated `NetworkServer.h` with corresponding method declaration and documentation. --- src/network/NetworkServer.cpp | 6 ++++++ src/network/NetworkServer.h | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/network/NetworkServer.cpp b/src/network/NetworkServer.cpp index e85383b..dbc72d5 100644 --- a/src/network/NetworkServer.cpp +++ b/src/network/NetworkServer.cpp @@ -86,4 +86,10 @@ namespace UNO::NETWORK { { this->io_context_.run(); } + + void NetworkServer::stop() + { + this->acceptor_.close(); + this->io_context_.stop(); + } } // namespace UNO::NETWORK \ No newline at end of file diff --git a/src/network/NetworkServer.h b/src/network/NetworkServer.h index e3202cd..961a13c 100644 --- a/src/network/NetworkServer.h +++ b/src/network/NetworkServer.h @@ -70,6 +70,11 @@ namespace UNO::NETWORK { */ void run(); + /** + * 停止网络进程 + */ + void stop(); + private: void accept(); };