Network: Add accessors to ENetHost/ENetPeer

This commit is contained in:
Lynix 2018-10-21 13:52:14 +02:00
parent 9674d7373c
commit 4e9d4c10da
5 changed files with 41 additions and 2 deletions

View File

@ -152,6 +152,7 @@ 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)

View File

@ -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);

View File

@ -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 <Nazara/Network/ENetHost.hpp>
#include <utility>
#include <Nazara/Network/Debug.hpp>
@ -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<ENetCompressor>&& compressor)
{
m_compressor = std::move(compressor);

View File

@ -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();

View File

@ -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 <Nazara/Network/DebugOff.hpp>
#include "ENetPeer.hpp"