From c76c01d1fd2ccbf91a6c3e0a120ed68c37ff106b Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Sun, 22 Jun 2025 17:38:23 +0800 Subject: API(server/clients:newClient): allow setting independent clients to wait fix!(server/clients:newClient): pass m_track also --- include/libsock/server/client.hpp | 4 ++-- include/libsock/server/clients.hpp | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'include/libsock') diff --git a/include/libsock/server/client.hpp b/include/libsock/server/client.hpp index 1d07837..0c3f869 100644 --- a/include/libsock/server/client.hpp +++ b/include/libsock/server/client.hpp @@ -49,7 +49,7 @@ class Client { private: void init(); - Client(SP server, SP clients, bool track = false, bool oneShot = true); + Client(SP server, SP clients, bool track = false, bool wait = false); WP m_self; WP m_wpServer; @@ -61,7 +61,7 @@ class Client { std::string m_ip; int m_port; bool m_track; - bool m_oneShot; + bool m_wait; std::optional m_szReading = std::nullopt; diff --git a/include/libsock/server/clients.hpp b/include/libsock/server/clients.hpp index dbe7099..4b67c23 100644 --- a/include/libsock/server/clients.hpp +++ b/include/libsock/server/clients.hpp @@ -21,10 +21,10 @@ struct SData { class Clients : public std::enable_shared_from_this { public: - static SP create(WP server, bool wait = false); + static SP create(WP server); ~Clients(); - SP newClient(std::function &)> cb = [](SP) {}); + SP newClient(std::function &)> cb = [](SP) {}, bool track = true, bool wait = false); void broadcast(const std::string &msg, std::optional> self = std::nullopt); // second param only specified when we // want to exclude the sender @@ -38,13 +38,11 @@ class Clients : public std::enable_shared_from_this { std::vector getDatas() const; private: - Clients(bool wait = false); - + Clients(); void broadcast(const SData &msg); std::vector>> m_vClients; std::vector m_vDatas; - bool m_wait; WP get(); -- cgit v1.2.3