UDPNetworkUtility accepts addresses by value, encapsulated ClientData

I started encapsulating ClientData, and I added the internals for the
heartbeat ssytem. However, when I took a look inside UDPNetworkUtility, I
realized that I didn't have to pass the IPaddresses by reference anymore.
Therefore, I've changed it to accept the addresses by value, and I'm
committing that change right away before I finish the heartbeat system.

This engine is really shaping up, I think.
This commit is contained in:
Kayne Ruse
2014-09-03 01:59:53 +10:00
parent 06922dc820
commit 79c7e48139
7 changed files with 79 additions and 25 deletions
+24 -2
View File
@@ -24,9 +24,31 @@
#include "SDL/SDL_net.h"
struct ClientData {
#include <chrono>
//TODO: ClientManager?
class ClientData {
public:
typedef std::chrono::steady_clock Clock;
ClientData() = default;
ClientData(IPaddress add): address(add) {}
~ClientData() = default;
IPaddress SetAddress(IPaddress add) { return address = add; }
IPaddress GetAddress() { return address; }
Clock::time_point GetLastBeat() { return lastBeat; }
int GetAttempts() { return attemptedBeats; }
int IncrementAttempts();
int ResetAttempts();
private:
IPaddress address = {0,0};
//TODO: ping system?
Clock::time_point lastBeat = Clock::now();
int attemptedBeats = 0;
};
#endif