1 #ifndef BLANK_NET_CONNECTION_HPP_
2 #define BLANK_NET_CONNECTION_HPP_
5 #include "../app/IntervalTimer.hpp"
13 class ConnectionHandler;
18 explicit Connection(const IPaddress &);
20 void SetHandler(ConnectionHandler *h) noexcept { handler = h; }
21 void RemoveHandler() noexcept { handler = nullptr; }
22 bool HasHandler() const noexcept { return handler; }
23 ConnectionHandler &Handler() noexcept { return *handler; }
25 const IPaddress &Address() const noexcept { return addr; }
27 bool Matches(const IPaddress &) const noexcept;
29 bool ShouldPing() const noexcept;
30 bool TimedOut() const noexcept;
32 void Close() noexcept { closed = true; }
33 bool Closed() const noexcept { return closed; }
37 std::uint16_t SendPing(UDPpacket &, UDPsocket);
39 std::uint16_t Send(UDPpacket &, UDPsocket);
40 void Received(const UDPpacket &);
43 void FlagSend() noexcept;
44 void FlagRecv() noexcept;
47 ConnectionHandler *handler;
49 CoarseTimer send_timer;
50 CoarseTimer recv_timer;
52 Packet::TControl ctrl_out;
53 Packet::TControl ctrl_in;