RpcTesterComponent.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. void HandleRPC_TestPassed(AzNetworking::IConnection* invokingConnection) override;
  26. private:
  27. void RunTests();
  28. AZ::ScheduledEvent m_delayTestRun{ [this]()
  29. {
  30. RunTests();
  31. }, AZ::Name("RpcTesterComponent") };
  32. };
  33. class RpcTesterComponentController
  34. : public RpcTesterComponentControllerBase
  35. {
  36. public:
  37. explicit RpcTesterComponentController(RpcTesterComponent& parent);
  38. void OnActivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
  39. void OnDeactivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
  40. void HandleRPC_AutonomousToAuthority(AzNetworking::IConnection* invokingConnection) override;
  41. void HandleRPC_AuthorityToAutonomous(AzNetworking::IConnection* invokingConnection) override;
  42. void HandleRPC_ServerToAuthority(AzNetworking::IConnection* invokingConnection) override;
  43. };
  44. }