RpcUnitTesterComponent.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0 OR MIT
  5. *
  6. */
  7. #pragma once
  8. #include <Tests/AutoGen/RpcUnitTesterComponent.AutoComponent.h>
  9. namespace MultiplayerTest
  10. {
  11. class RpcUnitTesterComponent
  12. : public RpcUnitTesterComponentBase
  13. {
  14. public:
  15. AZ_MULTIPLAYER_COMPONENT(MultiplayerTest::RpcUnitTesterComponent, s_rpcUnitTesterComponentConcreteUuid, MultiplayerTest::RpcUnitTesterComponentBase);
  16. static void Reflect(AZ::ReflectContext* context);
  17. void OnInit() override;
  18. void OnActivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
  19. void OnDeactivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
  20. RpcUnitTesterComponentController* GetTestController();
  21. void HandleRPC_AuthorityToClient([[maybe_unused]] AzNetworking::IConnection* invokingConnection) override
  22. {
  23. m_authorityToClientCalls++;
  24. }
  25. int m_authorityToClientCalls = 0;
  26. };
  27. class RpcUnitTesterComponentController
  28. : public RpcUnitTesterComponentControllerBase
  29. {
  30. public:
  31. explicit RpcUnitTesterComponentController(RpcUnitTesterComponent& parent);
  32. void OnActivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
  33. void OnDeactivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
  34. void HandleRPC_ServerToAuthority([[maybe_unused]] AzNetworking::IConnection* invokingConnection) override
  35. {
  36. m_serverToAuthorityCalls++;
  37. }
  38. int m_serverToAuthorityCalls = 0;
  39. void HandleRPC_AuthorityToAutonomous([[maybe_unused]] AzNetworking::IConnection* invokingConnection) override
  40. {
  41. m_authorityToAutonomousCalls++;
  42. }
  43. int m_authorityToAutonomousCalls = 0;
  44. void HandleRPC_AutonomousToAuthority([[maybe_unused]] AzNetworking::IConnection* invokingConnection) override
  45. {
  46. m_autonomousToAuthorityCalls++;
  47. }
  48. int m_autonomousToAuthorityCalls = 0;
  49. };
  50. }