3
0

ServerToClientConnectionData.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. #pragma once
  9. #include <Multiplayer/ConnectionData/IConnectionData.h>
  10. #include <Multiplayer/NetworkEntity/EntityReplication/EntityReplicationManager.h>
  11. namespace Multiplayer
  12. {
  13. class ServerToClientConnectionData final
  14. : public IConnectionData
  15. {
  16. public:
  17. ServerToClientConnectionData
  18. (
  19. AzNetworking::IConnection* connection,
  20. AzNetworking::IConnectionListener& connectionListener
  21. );
  22. ~ServerToClientConnectionData() override;
  23. void SetControlledEntity(NetworkEntityHandle primaryPlayerEntity);
  24. //! IConnectionData interface
  25. //! @{
  26. ConnectionDataType GetConnectionDataType() const override;
  27. AzNetworking::IConnection* GetConnection() const override;
  28. EntityReplicationManager& GetReplicationManager() override;
  29. void Update() override;
  30. bool CanSendUpdates() const override;
  31. void SetCanSendUpdates(bool canSendUpdates) override;
  32. bool DidHandshake() const override;
  33. void SetDidHandshake(bool didHandshake) override;
  34. //! @}
  35. NetworkEntityHandle GetPrimaryPlayerEntity();
  36. const NetworkEntityHandle& GetPrimaryPlayerEntity() const;
  37. const AZStd::string& GetProviderTicket() const;
  38. void SetProviderTicket(const AZStd::string&);
  39. private:
  40. void OnControlledEntityRemove();
  41. void OnControlledEntityMigration(const ConstNetworkEntityHandle& entityHandle, const HostId& remoteHostId);
  42. void OnGameplayStarted();
  43. EntityReplicationManager m_entityReplicationManager;
  44. NetworkEntityHandle m_controlledEntity;
  45. EntityStopEvent::Handler m_controlledEntityRemovedHandler;
  46. EntityServerMigrationEvent::Handler m_controlledEntityMigrationHandler;
  47. AZStd::string m_providerTicket;
  48. AzNetworking::IConnection* m_connection = nullptr;
  49. bool m_canSendUpdates = false;
  50. bool m_didHandshake = false;
  51. };
  52. }
  53. #include <Source/ConnectionData/ServerToClientConnectionData.inl>