summaryrefslogtreecommitdiff
path: root/include/libsock
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-06-22 17:38:23 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-06-22 18:04:43 +0800
commitc76c01d1fd2ccbf91a6c3e0a120ed68c37ff106b (patch)
treeba3f7bf6402539c0ca65eb8a3b88d85ed6b526eb /include/libsock
parent0028a4673d092e0dc8c57cce75cb158ad09826de (diff)
API(server/clients:newClient): allow setting independent clients to wait
fix!(server/clients:newClient): pass m_track also
Diffstat (limited to 'include/libsock')
-rw-r--r--include/libsock/server/client.hpp4
-rw-r--r--include/libsock/server/clients.hpp8
2 files changed, 5 insertions, 7 deletions
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> server, SP<Clients> clients, bool track = false, bool oneShot = true);
+ Client(SP<Server> server, SP<Clients> clients, bool track = false, bool wait = false);
WP<Client> m_self;
WP<Server> 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<std::string> 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<Clients> {
public:
- static SP<Clients> create(WP<Server> server, bool wait = false);
+ static SP<Clients> create(WP<Server> server);
~Clients();
- SP<Client> newClient(std::function<void(SP<Client> &)> cb = [](SP<Client>) {});
+ SP<Client> newClient(std::function<void(SP<Client> &)> cb = [](SP<Client>) {}, bool track = true, bool wait = false);
void broadcast(const std::string &msg, std::optional<WP<Client>> 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<Clients> {
std::vector<SData> getDatas() const;
private:
- Clients(bool wait = false);
-
+ Clients();
void broadcast(const SData &msg);
std::vector<std::pair<std::jthread, SP<Client>>> m_vClients;
std::vector<SData> m_vDatas;
- bool m_wait;
WP<Clients> get();