The server class
Now, it's time to take a look at the way things are handled on the other side of the wire. Let's begin by defining some constants:
#define HEARTBEAT_INTERVAL 1000 // Milliseconds. #define HEARTBEAT_RETRIES 5
Our server application is going to send out heartbeats every second and retry five times before it times out a client. Speaking of clients, there's additional information that we need to keep track of, which calls for a good data structure that holds it all:
struct ClientInfo{ sf::IpAddress m_clientIP; PortNumber m_clientPORT; sf::Time m_lastHeartbeat; sf::Time m_heartbeatSent; bool m_heartbeatWaiting; unsigned short m_heartbeatRetry; unsigned int m_latency; ClientInfo(const sf::IpAddress& l_ip, const PortNumber& l_port, const sf::Time& l_heartbeat): m_clientIP(l_ip), m_clientPORT(l_port), m_lastHeartbeat(l_heartbeat), m_heartbeatWaiting(false), m_heartbeatRetry(0), m_latency(0) {} ClientInfo&...