From 35216c30aea2f85966bb59999ad7293726b5cacb Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Thu, 19 Jun 2025 16:38:12 +0800 Subject: internal: seperate client and clientmanager header --- include/libsock/server/client.hpp | 42 ++++++--------------------------------- 1 file changed, 6 insertions(+), 36 deletions(-) (limited to 'include/libsock/server/client.hpp') diff --git a/include/libsock/server/client.hpp b/include/libsock/server/client.hpp index 9c7fc9f..1799f34 100644 --- a/include/libsock/server/client.hpp +++ b/include/libsock/server/client.hpp @@ -1,7 +1,6 @@ #pragma once #include "../types.hpp" -#include "server.hpp" #include #include #include @@ -9,12 +8,16 @@ #include #include #include -#include -#include namespace LibSock { namespace Server { +class Server; +class Clients; + +extern SP pServer; +extern SP pClients; + struct SRecvData { std::string data; const size_t size = 1024; @@ -31,9 +34,6 @@ enum eEventType : std::uint8_t { WRITE }; -class Clients; -inline SP pClients; - class Client { public: ~Client(); @@ -70,35 +70,5 @@ class Client { friend class Clients; }; -struct SData { - std::string msg; - std::optional> sender = std::nullopt; -}; - -class Clients { - public: - Clients(); - ~Clients(); - - WP newClient(std::optional)>> cb = std::nullopt); - - void broadcast(const std::string &msg, std::optional> self = std::nullopt); // second param only specified when we want to exclude the sender - void kick(WP client, const bool kill = false, const std::string &reason = "", std::optional>>::iterator &)>> cb = std::nullopt); - void addClient(const Client &client); - - void shutdownClients(std::optional>> &)>> cb = std::nullopt); - - SP getByIp(const std::string &ip) const; - std::vector> getClients() const; - std::vector getDatas() const; - - private: - void broadcast(const SData &msg); - - std::vector>> m_vClients; - std::vector m_vDatas; - - friend class Client; -}; } // namespace Server } // namespace LibSock -- cgit v1.2.3