]> git.localhorst.tv Git - blank.git/blobdiff - src/net/Connection.hpp
first draft for client/server architecture
[blank.git] / src / net / Connection.hpp
diff --git a/src/net/Connection.hpp b/src/net/Connection.hpp
new file mode 100644 (file)
index 0000000..49e9cda
--- /dev/null
@@ -0,0 +1,42 @@
+#ifndef BLANK_NET_CONNECTION_HPP_
+#define BLANK_NET_CONNECTION_HPP_
+
+#include "../app/IntervalTimer.hpp"
+
+#include <SDL_net.h>
+
+
+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