diff --git a/ChangeLog.md b/ChangeLog.md index a0bd88f53..ad8ee9527 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -209,6 +209,7 @@ Nazara Engine: - Added HandledObject::OnHandledObjectDestruction signal - Added physics function to control sleeping behavior - String::Number is now locale-independent +- Added ENetPeer::GetTotalByte[Received|Sent] Nazara Development Kit: - Added ImageWidget (#139) diff --git a/include/Nazara/Network/ENetPeer.hpp b/include/Nazara/Network/ENetPeer.hpp index 634f22402..7669bc142 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 UInt64 GetTotalByteReceived() const; + inline UInt64 GetTotalByteSent() const; inline UInt64 GetTotalPacketLost() const; inline UInt64 GetTotalPacketSent() const; @@ -237,6 +239,8 @@ namespace Nz UInt32 m_timeoutMaximum; UInt32 m_timeoutMinimum; UInt32 m_windowSize; + UInt64 m_totalByteReceived; + UInt64 m_totalByteSent; UInt64 m_totalPacketLost; UInt64 m_totalPacketSent; bool m_isSimulationEnabled; diff --git a/include/Nazara/Network/ENetPeer.inl b/include/Nazara/Network/ENetPeer.inl index 7820620ca..660614944 100644 --- a/include/Nazara/Network/ENetPeer.inl +++ b/include/Nazara/Network/ENetPeer.inl @@ -62,6 +62,16 @@ namespace Nz return m_state; } + inline UInt64 ENetPeer::GetTotalByteReceived() const + { + return m_totalByteReceived; + } + + inline UInt64 ENetPeer::GetTotalByteSent() const + { + return m_totalByteSent; + } + inline UInt64 ENetPeer::GetTotalPacketLost() const { return m_totalPacketLost; diff --git a/src/Nazara/Network/ENetHost.cpp b/src/Nazara/Network/ENetHost.cpp index f1008fec3..62bbf5684 100644 --- a/src/Nazara/Network/ENetHost.cpp +++ b/src/Nazara/Network/ENetHost.cpp @@ -541,6 +541,7 @@ namespace Nz { peer->m_address = m_receivedAddress; peer->m_incomingDataTotal += UInt32(m_receivedDataLength); + peer->m_totalByteReceived += UInt32(m_receivedDataLength); } auto commandError = [&]() -> bool diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index 823eaaf18..c897f4790 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -163,6 +163,8 @@ namespace Nz m_incomingUnsequencedGroup = 0; m_outgoingUnsequencedGroup = 0; m_eventData = 0; + m_totalByteReceived = 0; + m_totalByteSent = 0; m_totalPacketLost = 0; m_totalPacketSent = 0; m_totalWaitingData = 0; @@ -1085,6 +1087,7 @@ namespace Nz acknowledgment.sentTime = sentTime; m_outgoingDataTotal += sizeof(Acknowledgement); + m_totalByteSent += sizeof(Acknowledgement); m_acknowledgements.emplace_back(acknowledgment); @@ -1265,7 +1268,10 @@ namespace Nz void ENetPeer::SetupOutgoingCommand(OutgoingCommand& outgoingCommand) { - m_outgoingDataTotal += static_cast(ENetHost::GetCommandSize(outgoingCommand.command.header.command) + outgoingCommand.fragmentLength); + UInt32 commandSize = static_cast(ENetHost::GetCommandSize(outgoingCommand.command.header.command) + outgoingCommand.fragmentLength); + + m_outgoingDataTotal += commandSize; + m_totalByteSent += commandSize; if (outgoingCommand.command.header.channelID == 0xFF) {