A list of clients used by a server.
More...
#include <C_clientList.hpp>
|
void | clear () |
| Clear the client list and the event list.
|
void | sendToAll (SocketUdp &socket, Packet &pck) const |
| Directly send a packet to every client in the list.
|
void | sendToAll (TransmitPacketPtr const &pck) const |
| Push a packet to every client in the list.
|
void | add (Identity const &id, ClientSharedPtr const &newClient) |
| Add a client to the list.
|
void | remove (Identity const &id) |
| Remove a client from the list.
|
DataList::iterator | remove (DataList::const_iterator itPos, AccessLock< std::recursive_mutex > const &lock) |
| Remove a client from the list.
|
ClientSharedPtr | get (Identity const &id) const |
| Get a client from the list.
|
Data const * | getData (Identity const &id) const |
Data * | getData (Identity const &id) |
AccessLock< std::recursive_mutex > | acquireLock () const |
| Acquire a unique lock, with the ClientList mutex.
|
DataList::iterator | begin (AccessLock< std::recursive_mutex > const &lock) |
| Get the begin iterator of the ClientList.
|
DataList::const_iterator | begin (AccessLock< std::recursive_mutex > const &lock) const |
DataList::iterator | end (AccessLock< std::recursive_mutex > const &lock) |
DataList::const_iterator | end (AccessLock< std::recursive_mutex > const &lock) const |
std::size_t | getSize () const |
| Get the number of clients in the list.
|
void | watchEvent (bool on) |
| Enable or disable the gathering of client events.
|
bool | isWatchingEvent () const |
| Check if the gathering of client events is enabled.
|
void | pushClientEvent (ClientListEvent const &evt) |
| Manually push a client event.
|
ClientListEvent const & | getClientEvent (std::size_t index) const |
| Get the client event with its index.
|
std::size_t | getClientEventSize () const |
| Get the number of client events.
|
void | clearClientEvent () |
| Clear the client event list.
|
A list of clients used by a server.
◆ acquireLock()
AccessLock< std::recursive_mutex > fge::net::ClientList::acquireLock |
( |
| ) |
const |
Acquire a unique lock, with the ClientList mutex.
In order to use iterators, you have to acquire a unique lock from this ClientList. The lock is not differed and will lock the mutex.
- Returns
- A unique lock bound to this mutex
◆ add()
void fge::net::ClientList::add |
( |
Identity const & | id, |
|
|
ClientSharedPtr const & | newClient ) |
Add a client to the list.
- Parameters
-
id | The client's identity |
newClient | The client to add |
◆ begin()
DataList::iterator fge::net::ClientList::begin |
( |
AccessLock< std::recursive_mutex > const & | lock | ) |
|
Get the begin iterator of the ClientList.
You have to provide a valid reference to a unique lock acquire with the method ClientList::acquireLock(). This method will throw if one of this is not respected :
- The lock does not own the associated mutex.
- The mutex pointer of the lock does not correspond to this ClientList mutex.
- Parameters
-
lock | A unique lock bound to this mutex |
- Returns
- The begin iterator
◆ clear()
void fge::net::ClientList::clear |
( |
| ) |
|
Clear the client list and the event list.
◆ clearClientEvent()
void fge::net::ClientList::clearClientEvent |
( |
| ) |
|
Clear the client event list.
The client event list should be cleared manually after client checkup has been done.
◆ get()
ClientSharedPtr fge::net::ClientList::get |
( |
Identity const & | id | ) |
const |
Get a client from the list.
- Parameters
-
- Returns
- The client if found, nullptr otherwise
◆ getClientEvent()
ClientListEvent const & fge::net::ClientList::getClientEvent |
( |
std::size_t | index | ) |
const |
Get the client event with its index.
- Returns
- The client event
◆ getClientEventSize()
std::size_t fge::net::ClientList::getClientEventSize |
( |
| ) |
const |
Get the number of client events.
- Returns
- The number of client events
◆ getSize()
std::size_t fge::net::ClientList::getSize |
( |
| ) |
const |
Get the number of clients in the list.
- Returns
- Number of clients
◆ isWatchingEvent()
bool fge::net::ClientList::isWatchingEvent |
( |
| ) |
const |
Check if the gathering of client events is enabled.
- Returns
- True if enabled, false otherwise
◆ pushClientEvent()
Manually push a client event.
- Parameters
-
◆ remove() [1/2]
DataList::iterator fge::net::ClientList::remove |
( |
DataList::const_iterator | itPos, |
|
|
AccessLock< std::recursive_mutex > const & | lock ) |
Remove a client from the list.
You have to provide a valid reference to a unique lock acquire with the method ClientList::acquireLock().
- Parameters
-
itPos | The client's iterator |
lock | A unique lock bound to this mutex |
- Returns
- The iterator after the erased element
◆ remove() [2/2]
void fge::net::ClientList::remove |
( |
Identity const & | id | ) |
|
Remove a client from the list.
- Parameters
-
◆ sendToAll() [1/2]
void fge::net::ClientList::sendToAll |
( |
SocketUdp & | socket, |
|
|
Packet & | pck ) const |
Directly send a packet to every client in the list.
This function sends the packet to every client in the list without passing through a network thread and checking the latency.
- Parameters
-
socket | The UDP socket to use to send the packet |
pck | The packet to send |
◆ sendToAll() [2/2]
void fge::net::ClientList::sendToAll |
( |
TransmitPacketPtr const & | pck | ) |
const |
Push a packet to every client in the list.
- Parameters
-
◆ watchEvent()
void fge::net::ClientList::watchEvent |
( |
bool | on | ) |
|
Enable or disable the gathering of client events.
Default is disabled.
- Parameters
-
on | True to enable, false to disable |
The documentation for this class was generated from the following file: