Addressing PR feedback

Signed-off-by: kberg-amzn <karlberg@amazon.com>
This commit is contained in:
kberg-amzn
2021-11-03 19:40:20 -07:00
parent 8a3d055f8b
commit 7e65104155
4 changed files with 12 additions and 12 deletions
@@ -148,7 +148,7 @@ namespace AzNetworking
uint32_t m_connectionMtu = MaxUdpTransmissionUnit;
TimeoutId m_timeoutId;
int32_t m_timeoutCounter = 0;
uint32_t m_timeoutCounter = 0;
};
}
@@ -31,7 +31,7 @@ namespace AzNetworking
AZ_CVAR(bool, net_UdpTimeoutConnections, true, nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "Boolean value on whether we should timeout Udp connections");
AZ_CVAR(AZ::TimeMs, net_UdpPacketTimeSliceMs, AZ::TimeMs{ 8 }, nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "The number of milliseconds to allow for packet processing");
AZ_CVAR(int32_t, net_UdpUnackedHeartbeats, 5, nullptr, AZ::ConsoleFunctorFlags::Null, "The number of heartbeats to attempt to send to keep a connection alive before giving up");
AZ_CVAR(uint32_t, net_UdpUnackedHeartbeats, 5, nullptr, AZ::ConsoleFunctorFlags::Null, "The number of heartbeats to attempt to send to keep a connection alive before giving up");
AZ_CVAR(AZ::TimeMs, net_UdpDefaultTimeoutMs, AZ::TimeMs{ 10 * 1000 }, nullptr, AZ::ConsoleFunctorFlags::Null, "Time in milliseconds before we timeout an idle Udp connection");
AZ_CVAR(AZ::TimeMs, net_MinPacketTimeoutMs, AZ::TimeMs{ 200 }, nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "Minimum time to wait before timing out an unacked packet");
AZ_CVAR(int32_t, net_MaxTimeoutsPerFrame, 1000, nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "Maximum number of packet timeouts to allow to process in a single frame");
@@ -35,8 +35,8 @@ namespace Multiplayer
bool NetworkEntityAuthorityTracker::AddEntityAuthorityManager(ConstNetworkEntityHandle entityHandle, const HostId& newOwner)
{
bool ret = false;
auto timeoutData = m_timeoutDataMap.find(entityHandle.GetNetEntityId());
if (timeoutData != m_timeoutDataMap.end())
auto timeoutData = m_timedOutNetEntityIds.find(entityHandle.GetNetEntityId());
if (timeoutData != m_timedOutNetEntityIds.end())
{
AZLOG
(
@@ -45,7 +45,7 @@ namespace Multiplayer
aznumeric_cast<AZ::u64>(entityHandle.GetNetEntityId()),
newOwner.GetString().c_str()
);
m_timeoutDataMap.erase(timeoutData);
m_timedOutNetEntityIds.erase(timeoutData);
ret = true;
}
@@ -95,16 +95,16 @@ namespace Multiplayer
{
AZ_Assert
(
m_timeoutDataMap.find(entityHandle.GetNetEntityId()) == m_timeoutDataMap.end(),
m_timedOutNetEntityIds.find(entityHandle.GetNetEntityId()) == m_timedOutNetEntityIds.end(),
"Trying to add something twice to the timeout map, this is unexpected"
);
m_timeoutDataMap.insert(entityHandle.GetNetEntityId());
m_timedOutNetEntityIds.insert(entityHandle.GetNetEntityId());
AZ::Interface<AZ::IEventScheduler>::Get()->AddCallback([this, netEntityId = entityHandle.GetNetEntityId()]
{
auto timeoutData = m_timeoutDataMap.find(netEntityId);
if (timeoutData != m_timeoutDataMap.end())
auto timeoutData = m_timedOutNetEntityIds.find(netEntityId);
if (timeoutData != m_timedOutNetEntityIds.end())
{
m_timeoutDataMap.erase(timeoutData);
m_timedOutNetEntityIds.erase(timeoutData);
ConstNetworkEntityHandle entityHandle = m_networkEntityManager.GetEntity(netEntityId);
if (auto entity = entityHandle.GetEntity())
{
@@ -13,6 +13,7 @@
#include <AzCore/std/containers/unordered_map.h>
#include <AzNetworking/DataStructures/TimeoutQueue.h>
#include <Source/NetworkEntity/NetworkEntityTracker.h>
#include <Multiplayer/NetworkEntity/INetworkEntityManager.h>
namespace Multiplayer
{
@@ -32,10 +33,9 @@ namespace Multiplayer
private:
NetworkEntityAuthorityTracker& operator= (const NetworkEntityAuthorityTracker&) = delete;
using TimeoutDataMap = AZStd::unordered_set<NetEntityId>;
using EntityAuthorityMap = AZStd::unordered_map<NetEntityId, AZStd::vector<HostId>>;
TimeoutDataMap m_timeoutDataMap;
NetEntityIdSet m_timedOutNetEntityIds;
EntityAuthorityMap m_entityAuthorityMap;
INetworkEntityManager& m_networkEntityManager;