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:
+24
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user