4#include <unordered_map> 
   86    void ping(uint64_t 
id);
 
  106        virtual const char* 
what() 
const throw()
 
  108            return "Client disconnected";
 
  110        uint64_t 
id()
 const { 
return m_id; }
 
  119    std::unordered_map<uint64_t, std::chrono::time_point<std::chrono::high_resolution_clock>> 
m_pings;
 
  128    std::unordered_map<uint64_t, std::shared_ptr<Connection>>   m_connections;
 
  129    std::mutex                                  m_connections_mutex;
 
  131    uint64_t                                    m_ids_counter;
 
  133    uint64_t get_new_id();
 
  135    int     readData(
Connection & connection, uint64_t 
id);
 
  136    int     sendData(
Connection & connection, uint64_t 
id);
 
  137    void    emptyOutgoingPackets();
 
  138    void    emptyOldPings();
 
  140    void sendPacket(std::shared_ptr<IPacket> packet, 
const uint64_t & 
id);
 
  141    void sendAllExcept(std::shared_ptr<IPacket> packet, 
const uint64_t & except_id);
 
  142    void sendAll(std::shared_ptr<IPacket> packet);
 
a bufferised and thread safe RAII wrapper for a socket representing a connection.
Definition: Connection.hpp:29
Definition: PacketFactory.hpp:8
Definition: Poller.hpp:13
a class that represents a server socket. you can accept connections from clients.
Definition: ServerSocket.hpp:16
Definition: Server.hpp:103
virtual const char * what() const
Definition: Server.hpp:106
uint64_t id() const
Definition: Server.hpp:110
ClientDisconnected(uint64_t id)
Definition: Server.hpp:105
The server side interface with the network module.
Definition: Server.hpp:33
void send(const sendInfo &info)
Definition: Server.cpp:185
std::unordered_map< uint64_t, std::chrono::time_point< std::chrono::high_resolution_clock > > m_pings
map used to store the time a ping was sent to a client
Definition: Server.hpp:119
void disconnect(uint64_t id)
disconnect a client
Definition: Server.cpp:151
static constexpr int PING_TIMEOUT_MS
Definition: Server.hpp:35
~Server()
Definition: Server.cpp:10
flags
Definition: Server.hpp:47
@ ASYNC
Definition: Server.hpp:50
@ ALLEXCEPT
Definition: Server.hpp:49
@ ALL
Definition: Server.hpp:48
ThreadSafePacketQueue & getIncomingPackets()
Get a ref to the list of packet that have been received.
Definition: Server.hpp:100
Server & operator=(Server &&other)=delete
Server(Server &&other)=delete
Server & operator=(const Server &other)=delete
Server(const Server &other)=delete
void ping(uint64_t id)
send a ping packet to a client
Definition: Server.cpp:178
void runOnce(int timeout_ms)
Definition: Server.cpp:14
arg struct used to send a packet
Definition: Server.hpp:57
std::shared_ptr< IPacket > packet
shared pointer to the packet to send
Definition: Server.hpp:62
uint8_t flag
bitfield containing flags from the flags enum
Definition: Server.hpp:68