From 4e9d4c10da40597cfb851e4a8c52d107363a9ceb Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 21 Oct 2018 13:52:14 +0200 Subject: [PATCH] Network: Add accessors to ENetHost/ENetPeer --- ChangeLog.md | 3 ++- include/Nazara/Network/ENetHost.hpp | 6 +++++- include/Nazara/Network/ENetHost.inl | 21 +++++++++++++++++++++ include/Nazara/Network/ENetPeer.hpp | 2 ++ include/Nazara/Network/ENetPeer.inl | 11 +++++++++++ 5 files changed, 41 insertions(+), 2 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index e0091913d..669f8cc9e 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -152,7 +152,8 @@ Nazara Engine: - ⚠️ Use of the new Angle class instead of floating point angle - It is now possible to set elasticity/friction/surface bodies of 2D colliders and change it at runtime on RigidBody2D - ObjectHandle were remade and should be way more optimized now - + - Added ENetHost and ENetPeer accessor to total packet/data received/sent/lost + Nazara Development Kit: - Added ImageWidget (#139) - ⚠️ Removed TextAreaWidget::GetLineCount diff --git a/include/Nazara/Network/ENetHost.hpp b/include/Nazara/Network/ENetHost.hpp index 28a2d2da5..01f59234b 100644 --- a/include/Nazara/Network/ENetHost.hpp +++ b/include/Nazara/Network/ENetHost.hpp @@ -58,8 +58,12 @@ namespace Nz void Flush(); - inline Nz::IpAddress GetBoundAddress() const; + inline IpAddress GetBoundAddress() const; inline UInt32 GetServiceTime() const; + inline UInt32 GetTotalReceivedPackets() const; + inline UInt64 GetTotalReceivedData() const; + inline UInt64 GetTotalSentData() const; + inline UInt32 GetTotalSentPackets() const; int Service(ENetEvent* event, UInt32 timeout); diff --git a/include/Nazara/Network/ENetHost.inl b/include/Nazara/Network/ENetHost.inl index 11ee91c80..fcb6bf6de 100644 --- a/include/Nazara/Network/ENetHost.inl +++ b/include/Nazara/Network/ENetHost.inl @@ -2,6 +2,7 @@ // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp +#include #include #include @@ -63,6 +64,26 @@ namespace Nz return m_serviceTime; } + inline UInt32 ENetHost::GetTotalReceivedPackets() const + { + return m_totalReceivedPackets; + } + + inline UInt64 ENetHost::GetTotalReceivedData() const + { + return m_totalReceivedData; + } + + inline UInt64 ENetHost::GetTotalSentData() const + { + return m_totalSentData; + } + + inline UInt32 ENetHost::GetTotalSentPackets() const + { + return m_totalSentPackets; + } + inline void ENetHost::SetCompressor(std::unique_ptr&& compressor) { m_compressor = std::move(compressor); diff --git a/include/Nazara/Network/ENetPeer.hpp b/include/Nazara/Network/ENetPeer.hpp index f2435f579..7cba0d4a5 100644 --- a/include/Nazara/Network/ENetPeer.hpp +++ b/include/Nazara/Network/ENetPeer.hpp @@ -56,6 +56,8 @@ namespace Nz inline UInt16 GetPeerId() const; inline UInt32 GetRoundTripTime() const; inline ENetPeerState GetState() const; + inline UInt32 GetTotalPacketLost() const; + inline UInt32 GetTotalPacketSent() const; inline bool HasPendingCommands(); diff --git a/include/Nazara/Network/ENetPeer.inl b/include/Nazara/Network/ENetPeer.inl index 3f8ffa846..55745ce56 100644 --- a/include/Nazara/Network/ENetPeer.inl +++ b/include/Nazara/Network/ENetPeer.inl @@ -62,6 +62,16 @@ namespace Nz return m_state; } + inline UInt32 ENetPeer::GetTotalPacketLost() const + { + return m_totalPacketLost; + } + + inline UInt32 ENetPeer::GetTotalPacketSent() const + { + return m_totalPacketSent; + } + inline bool ENetPeer::HasPendingCommands() { return m_outgoingReliableCommands.empty() && m_outgoingUnreliableCommands.empty() && m_sentReliableCommands.empty(); @@ -94,3 +104,4 @@ namespace Nz } #include +#include "ENetPeer.hpp"