RpcTesterComponent.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 <Source/AutoGen/RpcTesterComponent.AutoComponent.h>
  9. namespace MultiplayerSample
  10. {
  11. class RpcTesterComponent
  12. : public RpcTesterComponentBase
  13. {
  14. friend class RpcTesterComponentController;
  15. public:
  16. AZ_MULTIPLAYER_COMPONENT(MultiplayerSample::RpcTesterComponent, s_rpcTesterComponentConcreteUuid, MultiplayerSample::RpcTesterComponentBase);
  17. static void Reflect(AZ::ReflectContext* context);
  18. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
  19. {
  20. required.push_back(AZ_CRC_CE("MaterialProviderService"));
  21. RpcTesterComponentBase::GetRequiredServices(required);
  22. }
  23. void OnActivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
  24. void OnDeactivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
  25. #if AZ_TRAIT_CLIENT
  26. void HandleRPC_TestPassed(AzNetworking::IConnection* invokingConnection) override;
  27. #endif
  28. private:
  29. void RunTests();
  30. AZ::ScheduledEvent m_delayTestRun{ [this]()
  31. {
  32. RunTests();
  33. }, AZ::Name("RpcTesterComponent") };
  34. };
  35. class RpcTesterComponentController
  36. : public RpcTesterComponentControllerBase
  37. {
  38. public:
  39. explicit RpcTesterComponentController(RpcTesterComponent& parent);
  40. void OnActivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
  41. void OnDeactivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
  42. #if AZ_TRAIT_CLIENT
  43. void HandleRPC_AuthorityToAutonomous(AzNetworking::IConnection* invokingConnection) override;
  44. #endif
  45. #if AZ_TRAIT_SERVER
  46. void HandleRPC_AutonomousToAuthority(AzNetworking::IConnection* invokingConnection) override;
  47. void HandleRPC_ServerToAuthority(AzNetworking::IConnection* invokingConnection) override;
  48. #endif
  49. };
  50. }