1 #ifndef BLANK_NET_CONNECTIONHANDLER_HPP_
2 #define BLANK_NET_CONNECTIONHANDLER_HPP_
11 class ConnectionHandler {
16 float PacketLoss() const noexcept { return packet_loss; }
18 void PacketLost(std::uint16_t);
19 void PacketReceived(std::uint16_t);
21 void Handle(const UDPpacket &);
23 virtual void OnTimeout() { }
26 void UpdatePacketLoss() noexcept;
28 // called as soon as the remote end ack'd given packet
29 virtual void OnPacketReceived(std::uint16_t) { }
30 // called if the remote end probably didn't get given packet
31 virtual void OnPacketLost(std::uint16_t) { }
33 virtual void On(const Packet::Ping &) { }
34 virtual void On(const Packet::Login &) { }
35 virtual void On(const Packet::Join &) { }
36 virtual void On(const Packet::Part &) { }
37 virtual void On(const Packet::PlayerUpdate &) { }
38 virtual void On(const Packet::SpawnEntity &) { }
39 virtual void On(const Packet::DespawnEntity &) { }
40 virtual void On(const Packet::EntityUpdate &) { }
41 virtual void On(const Packet::PlayerCorrection &) { }
42 virtual void On(const Packet::ChunkBegin &) { }
43 virtual void On(const Packet::ChunkData &) { }
44 virtual void On(const Packet::BlockUpdate &) { }
47 unsigned int packets_lost;
48 unsigned int packets_received;