diff options
Diffstat (limited to 'include/libsock/server/clients.hpp')
| -rw-r--r-- | include/libsock/server/clients.hpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/include/libsock/server/clients.hpp b/include/libsock/server/clients.hpp index d8c1921..b18c043 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(); + static SP<Clients> create(WP<Server> server); ~Clients(); - WP<Client> newClient(std::function<void(const WP<Client> &)> loopFunc = [](const WP<Client> &) { ; }, SP<Server> server = pServer); + SP<Client> newClient(std::function<void(const WP<Client> &)> loopFunc = [](const WP<Client> &) { ; }); void broadcast(const std::string &msg, std::optional<WP<Client>> self = std::nullopt); // second param only specified when we // want to exclude the sender @@ -44,10 +44,13 @@ class Clients : public std::enable_shared_from_this<Clients> { std::vector<std::pair<std::jthread, SP<Client>>> m_vClients; std::vector<SData> m_vDatas; - SP<Clients> get(); + WP<Clients> get(); + + WP<Clients> m_self; + WP<Server> m_wpServer; friend class Client; }; -inline SP<Clients> pClients; +inline std::vector<WP<Clients>> vpClients; } // namespace Server } // namespace LibSock |
