X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fnet%2FConnectionHandler.hpp;h=ff5e0e42204c8ab9998b83ac9630aae71e19d210;hb=b4e5dad2ed5c7e77573de413f3bf5be88577856d;hp=be01d10add35ab3b597c4cec5c5efa5d8d17f4c5;hpb=c256dca7c6ca2c7f8eeffae53c02fe62bd892198;p=blank.git diff --git a/src/net/ConnectionHandler.hpp b/src/net/ConnectionHandler.hpp index be01d10..ff5e0e4 100644 --- a/src/net/ConnectionHandler.hpp +++ b/src/net/ConnectionHandler.hpp @@ -1,6 +1,7 @@ #ifndef BLANK_NET_CONNECTIONHANDLER_HPP_ #define BLANK_NET_CONNECTIONHANDLER_HPP_ +#include "CongestionControl.hpp" #include "Packet.hpp" #include @@ -13,25 +14,20 @@ class ConnectionHandler { public: ConnectionHandler(); - /// packet loss as factor - float PacketLoss() const noexcept { return packet_loss; } - /// smooth average round trip time in milliseconds - float RoundTripTime() const noexcept { return rtt; } + const CongestionControl &NetStat() const noexcept { return cc; } - void PacketSent(std::uint16_t); + void PacketSent(std::uint16_t) noexcept; void PacketLost(std::uint16_t); void PacketReceived(std::uint16_t); + void PacketIn(const UDPpacket &) noexcept; + void PacketOut(const UDPpacket &) noexcept; + void Handle(const UDPpacket &); virtual void OnTimeout() { } private: - void UpdatePacketLoss() noexcept; - void UpdateRTT(std::uint16_t) noexcept; - bool SamplePacket(std::uint16_t) const noexcept; - int HeadDiff(std::uint16_t) const noexcept; - // called as soon as the remote end ack'd given packet virtual void OnPacketReceived(std::uint16_t) { } // called if the remote end probably didn't get given packet @@ -52,14 +48,7 @@ private: virtual void On(const Packet::Message &) { } private: - unsigned int packets_lost; - unsigned int packets_received; - float packet_loss; - - Uint32 stamps[16]; - std::size_t stamp_cursor; - std::uint16_t stamp_last; - float rtt; + CongestionControl cc; };