Network/RUdpConnection: Add packet loss simulator

Former-commit-id: 8778d54b5b5a9038ec6b9d888cf6c49ad6c5721c
This commit is contained in:
Lynix
2016-04-17 17:56:02 +02:00
parent 1a5dd41407
commit 76bc70b210
3 changed files with 26 additions and 2 deletions

View File

@@ -121,6 +121,19 @@ namespace Nz
NazaraError("PacketReliability not handled (0x" + String::Number(reliability, 16) + ')');
return false;
}
inline void RUdpConnection::SimulateNetwork(double packetLoss)
{
NazaraAssert(packetLoss >= 0.0 && packetLoss <= 1.0, "Packet loss must be in range [0..1]");
if (packetLoss > 0.0)
{
m_isSimulationEnabled = true;
m_packetLossProbability = std::bernoulli_distribution(packetLoss);
}
else
m_isSimulationEnabled = false;
}
}
#include <Nazara/Network/DebugOff.hpp>