Nazara/Network: Add GetTotalByte[Received|Sent]

This commit is contained in:
Lynix 2019-12-28 17:31:21 +01:00
parent 9f8e83087a
commit 56243f5a12
5 changed files with 23 additions and 1 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -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<UInt32>(ENetHost::GetCommandSize(outgoingCommand.command.header.command) + outgoingCommand.fragmentLength);
UInt32 commandSize = static_cast<UInt32>(ENetHost::GetCommandSize(outgoingCommand.command.header.command) + outgoingCommand.fragmentLength);
m_outgoingDataTotal += commandSize;
m_totalByteSent += commandSize;
if (outgoingCommand.command.header.channelID == 0xFF)
{