17#ifndef _FGE_C_CLIENTLIST_HPP_INCLUDED
18#define _FGE_C_CLIENTLIST_HPP_INCLUDED
20#include "FastEngine/fge_extern.hpp"
21#include "C_client.hpp"
25#include <unordered_map>
32using ClientSharedPtr = std::shared_ptr<fge::net::Client>;
47 fge::net::ClientListEvent::Events _event;
59 using ClientListData = std::unordered_map<fge::net::Identity, fge::net::ClientSharedPtr, fge::net::IdentityHash>;
60 using ClientEventList = std::deque<fge::net::ClientListEvent>;
85 void sendToAll(fge::net::TransmissionPacketPtr
const& pck);
110 fge::net::ClientList::ClientListData::iterator
remove(fge::net::ClientList::ClientListData::const_iterator itPos,
111 std::unique_lock<std::recursive_mutex>
const& lock);
144 fge::net::ClientList::ClientListData::iterator
begin(std::unique_lock<std::recursive_mutex>
const& lock);
145 fge::net::ClientList::ClientListData::const_iterator
146 begin(std::unique_lock<std::recursive_mutex>
const& lock)
const;
147 fge::net::ClientList::ClientListData::iterator end(std::unique_lock<std::recursive_mutex>
const& lock);
148 fge::net::ClientList::ClientListData::const_iterator end(std::unique_lock<std::recursive_mutex>
const& lock)
const;
199 fge::net::ClientList::ClientListData g_data;
200 fge::net::ClientList::ClientEventList g_events;
201 mutable std::recursive_mutex g_mutex;
202 bool g_enableClientEventsFlag =
false;
A list of clients used by a server.
Definition C_clientList.hpp:57
void remove(fge::net::Identity const &id)
Remove a client from the list.
void clear()
Clear the client list and the event list.
bool isWatchingEvent() const
Check if the gathering of client events is enabled.
void clearClientEvent()
Clear the client event list.
fge::net::ClientSharedPtr get(fge::net::Identity const &id) const
Get a client from the list.
void sendToAll(fge::net::TransmissionPacketPtr const &pck)
Push a packet to every clients in the list.
void sendToAll(fge::net::SocketUdp &socket, fge::net::Packet &pck)
Directly send a packet to every clients in the list.
void watchEvent(bool on)
Enable or disable the gathering of client events.
fge::net::ClientListEvent const & getClientEvent(std::size_t index) const
Get the client event with its index.
void add(fge::net::Identity const &id, fge::net::ClientSharedPtr const &newClient)
Add a client to the list.
fge::net::ClientList::ClientListData::iterator begin(std::unique_lock< std::recursive_mutex > const &lock)
Get the begin iterator of the ClientList.
fge::net::ClientList::ClientListData::iterator remove(fge::net::ClientList::ClientListData::const_iterator itPos, std::unique_lock< std::recursive_mutex > const &lock)
Remove a client from the list.
std::unique_lock< std::recursive_mutex > acquireLock() const
Acquire a unique lock, with the ClientList mutex.
void pushClientEvent(fge::net::ClientListEvent const &evt)
Manually push a client event.
std::size_t getSize() const
Get the number of clients in the list.
std::size_t getClientEventSize() const
Get the number of client events.
Definition C_packet.hpp:70
A wrapper for UDP sockets inheriting from Socket.
Definition C_socket.hpp:267
Represents an event on the client list (client added, client removed, ...)
Definition C_clientList.hpp:40
A class to represent a client or server identity with an IP address and a port.
Definition C_identity.hpp:31