![]() |
FastEngine 0.9.5
A multiplayer oriented 2D engine made with Vulkan.
|
A list of clients used by a server. More...
#include <C_clientList.hpp>
Classes | |
| struct | Event |
| Represents an event on the client list (client added, client removed, ...). More... | |
Public Types | |
| using | DataList = std::unordered_map<Identity, ClientSharedPtr, IdentityHash> |
| using | EventList = std::deque<Event> |
Public Member Functions | |
| ClientList (ClientList const &r) | |
| ClientList (ClientList &&r) noexcept | |
| ClientList & | operator= (ClientList const &r) |
| ClientList & | operator= (ClientList &&r) noexcept |
| 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. | |
| bool | moveTo (ClientList &targetList, Identity const &id) |
| 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. | |
| 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 (Event const &evt) |
| Manually push a client event. | |
| Event 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.
| 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.
| void fge::net::ClientList::add | ( | Identity const & | id, |
| ClientSharedPtr const & | newClient ) |
Add a client to the list.
| id | The client's identity |
| newClient | The client to add |
| 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 :
| lock | A unique lock bound to this mutex |
| void fge::net::ClientList::clear | ( | ) |
Clear the client list and the event list.
| void fge::net::ClientList::clearClientEvent | ( | ) |
Clear the client event list.
The client event list should be cleared manually after client checkup has been done.
| ClientSharedPtr fge::net::ClientList::get | ( | Identity const & | id | ) | const |
Get a client from the list.
| id | The client's identity |
| Event const & fge::net::ClientList::getClientEvent | ( | std::size_t | index | ) | const |
Get the client event with its index.
| std::size_t fge::net::ClientList::getClientEventSize | ( | ) | const |
Get the number of client events.
| std::size_t fge::net::ClientList::getSize | ( | ) | const |
Get the number of clients in the list.
| bool fge::net::ClientList::isWatchingEvent | ( | ) | const |
Check if the gathering of client events is enabled.
| void fge::net::ClientList::pushClientEvent | ( | Event const & | evt | ) |
Manually push a client event.
| evt | A client event |
| 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().
| itPos | The client's iterator |
| lock | A unique lock bound to this mutex |
| void fge::net::ClientList::remove | ( | Identity const & | id | ) |
Remove a client from the list.
| id | The client's identity |
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.
| socket | The UDP socket to use to send the packet |
| pck | The packet to send |
| void fge::net::ClientList::sendToAll | ( | TransmitPacketPtr const & | pck | ) | const |
Push a packet to every client in the list.
| pck | The packet to push |
| void fge::net::ClientList::watchEvent | ( | bool | on | ) |
Enable or disable the gathering of client events.
Default is disabled.
| on | True to enable, false to disable |