ClientToServerConnectionData.cpp 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <Source/ConnectionData/ClientToServerConnectionData.h>
  9. namespace Multiplayer
  10. {
  11. // This can be used to help mitigate client side performance when large numbers of entities are created off the network
  12. AZ_CVAR(uint32_t, cl_ClientMaxRemoteEntitiesPendingCreationCount, AZStd::numeric_limits<uint32_t>::max(), nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "Maximum number of entities that we have sent to the client, but have not had a confirmation back from the client");
  13. AZ_CVAR(AZ::TimeMs, cl_ClientEntityReplicatorPendingRemovalTimeMs, AZ::TimeMs{ 10000 }, nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "How long should wait prior to removing an entity for the client through a change in the replication window, entity deletes are still immediate");
  14. AZ_CVAR(AZ::TimeMs, cl_DefaultNetworkEntityActivationTimeSliceMs, AZ::Time::ZeroTimeMs, nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "Max Ms to use to activate entities coming from the network, 0 means instantiate everything");
  15. ClientToServerConnectionData::ClientToServerConnectionData
  16. (
  17. AzNetworking::IConnection* connection,
  18. AzNetworking::IConnectionListener& connectionListener,
  19. const AZStd::string& providerTicket
  20. )
  21. : m_connection(connection)
  22. , m_entityReplicationManager(*connection, connectionListener, EntityReplicationManager::Mode::LocalClientToRemoteServer)
  23. , m_providerTicket(providerTicket)
  24. {
  25. m_entityReplicationManager.SetMaxRemoteEntitiesPendingCreationCount(cl_ClientMaxRemoteEntitiesPendingCreationCount);
  26. m_entityReplicationManager.SetEntityPendingRemovalMs(cl_ClientEntityReplicatorPendingRemovalTimeMs);
  27. m_entityReplicationManager.SetEntityActivationTimeSliceMs(cl_DefaultNetworkEntityActivationTimeSliceMs);
  28. }
  29. ClientToServerConnectionData::~ClientToServerConnectionData()
  30. {
  31. m_entityReplicationManager.Clear(false);
  32. }
  33. ConnectionDataType ClientToServerConnectionData::GetConnectionDataType() const
  34. {
  35. return ConnectionDataType::ClientToServer;
  36. }
  37. AzNetworking::IConnection* ClientToServerConnectionData::GetConnection() const
  38. {
  39. return m_connection;
  40. }
  41. EntityReplicationManager& ClientToServerConnectionData::GetReplicationManager()
  42. {
  43. return m_entityReplicationManager;
  44. }
  45. void ClientToServerConnectionData::Update()
  46. {
  47. m_entityReplicationManager.ActivatePendingEntities();
  48. m_entityReplicationManager.SendUpdates();
  49. }
  50. }