X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fnet%2FConnectionHandler.hpp;h=76103fecdf11a5db2f36aaf1088e42c00f5d158b;hb=225a7e66ed3f3f03ab458ab39c914ed55cd69600;hp=be01d10add35ab3b597c4cec5c5efa5d8d17f4c5;hpb=c256dca7c6ca2c7f8eeffae53c02fe62bd892198;p=blank.git diff --git a/src/net/ConnectionHandler.hpp b/src/net/ConnectionHandler.hpp index be01d10..76103fe 100644 --- a/src/net/ConnectionHandler.hpp +++ b/src/net/ConnectionHandler.hpp @@ -17,11 +17,18 @@ public: float PacketLoss() const noexcept { return packet_loss; } /// smooth average round trip time in milliseconds float RoundTripTime() const noexcept { return rtt; } + /// estimated kilobytes transferred per second + float Upstream() const noexcept { return tx_kbps; } + /// estimated kilobytes received per second + float Downstream() const noexcept { return rx_kbps; } - 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() { } @@ -31,6 +38,7 @@ private: void UpdateRTT(std::uint16_t) noexcept; bool SamplePacket(std::uint16_t) const noexcept; int HeadDiff(std::uint16_t) const noexcept; + void UpdateStats() noexcept; // called as soon as the remote end ack'd given packet virtual void OnPacketReceived(std::uint16_t) { } @@ -61,6 +69,12 @@ private: std::uint16_t stamp_last; float rtt; + Uint32 next_sample; + std::size_t tx_bytes; + std::size_t rx_bytes; + float tx_kbps; + float rx_kbps; + }; }