PresenceSystemComponent.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 <AzCore/Component/Component.h>
  10. #include <Presence/PresenceRequestBus.h>
  11. #include <AzCore/std/parallel/atomic.h>
  12. #include <AzCore/std/string/string.h>
  13. #include <AzCore/Component/TickBus.h>
  14. namespace Presence
  15. {
  16. class PresenceSystemComponent
  17. : public AZ::Component
  18. , protected PresenceRequestBus::Handler
  19. {
  20. #define DEBUG_PRESENCE 1
  21. public:
  22. ////////////////////////////////////////////////////////////////////////////////////////
  23. //! Component setup
  24. AZ_COMPONENT(PresenceSystemComponent, "{1B04E968-2729-4CA0-8841-21E50FE9133C}");
  25. ////////////////////////////////////////////////////////////////////////////////////////
  26. //! Component overrides
  27. static void Reflect(AZ::ReflectContext* context);
  28. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  29. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  30. protected:
  31. ////////////////////////////////////////////////////////////////////////
  32. //! AZ::Component interface implementation
  33. void Activate() override;
  34. void Deactivate() override;
  35. ////////////////////////////////////////////////////////////////////////
  36. //! PresenceRequestBus interface implementation
  37. void SetPresence(const SetPresenceParams& params) override;
  38. void QueryPresence(const QueryPresenceParams& params) override;
  39. public:
  40. ////////////////////////////////////////////////////////////////////////
  41. //! Base class for platform specific implementations
  42. class Implementation
  43. {
  44. public:
  45. AZ_CLASS_ALLOCATOR(Implementation, AZ::SystemAllocator);
  46. static Implementation* Create(PresenceSystemComponent& presenceSystemComponent);
  47. Implementation(PresenceSystemComponent& presenceSystemComponent);
  48. AZ_DISABLE_COPY_MOVE(Implementation);
  49. virtual ~Implementation();
  50. virtual void SetPresence(const SetPresenceParams& params) = 0;
  51. virtual void QueryPresence(const QueryPresenceParams& params) = 0;
  52. static void OnPresenceSetComplete(const SetPresenceParams& params);
  53. static void OnPresenceQueriedComplete(const QueryPresenceParams& params, const PresenceDetails& details);
  54. PresenceSystemComponent& m_presenceSystemComponent;
  55. };
  56. private:
  57. ////////////////////////////////////////////////////////////////////////////////////////
  58. //! Private pointer to the platform specific implementation
  59. AZStd::unique_ptr<Implementation> m_pimpl;
  60. };
  61. }