X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fnet%2FConnection.hpp;fp=src%2Fnet%2FConnection.hpp;h=49e9cdac3989eee5bd7b74969bd193502c3b3abc;hb=9ebe2c320fd9f94266ab93fa2f9d9908a0a284d3;hp=0000000000000000000000000000000000000000;hpb=f27b8bb27fa87487bb5d29a1456e610255287b04;p=blank.git diff --git a/src/net/Connection.hpp b/src/net/Connection.hpp new file mode 100644 index 0000000..49e9cda --- /dev/null +++ b/src/net/Connection.hpp @@ -0,0 +1,42 @@ +#ifndef BLANK_NET_CONNECTION_HPP_ +#define BLANK_NET_CONNECTION_HPP_ + +#include "../app/IntervalTimer.hpp" + +#include + + +namespace blank { + +class Connection { + +public: + explicit Connection(const IPaddress &); + + const IPaddress &Address() const noexcept { return addr; } + + bool Matches(const IPaddress &) const noexcept; + + void FlagSend() noexcept; + void FlagRecv() noexcept; + + bool ShouldPing() const noexcept; + bool TimedOut() const noexcept; + + void Update(int dt); + + + void SendPing(UDPpacket &, UDPsocket); + + void Send(UDPpacket &, UDPsocket); + +private: + IPaddress addr; + IntervalTimer send_timer; + IntervalTimer recv_timer; + +}; + +} + +#endif