December 2015
Beginner to intermediate
522 pages
11h 21m
English
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 ...Read now
Unlock full access