]> git.localhorst.tv Git - blank.git/blob - src/net/Connection.hpp
client-side implementation of login packet
[blank.git] / src / net / Connection.hpp
1 #ifndef BLANK_NET_CONNECTION_HPP_
2 #define BLANK_NET_CONNECTION_HPP_
3
4 #include "../app/IntervalTimer.hpp"
5
6 #include <SDL_net.h>
7
8
9 namespace blank {
10
11 class Connection {
12
13 public:
14         explicit Connection(const IPaddress &);
15
16         const IPaddress &Address() const noexcept { return addr; }
17
18         bool Matches(const IPaddress &) const noexcept;
19
20         void FlagSend() noexcept;
21         void FlagRecv() noexcept;
22
23         bool ShouldPing() const noexcept;
24         bool TimedOut() const noexcept;
25
26         void Update(int dt);
27
28
29         void SendPing(UDPpacket &, UDPsocket);
30
31         void Send(UDPpacket &, UDPsocket);
32
33 private:
34         IPaddress addr;
35         IntervalTimer send_timer;
36         IntervalTimer recv_timer;
37
38 };
39
40 }
41
42 #endif