NAP
portalservice.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 
5 #pragma once
6 
7 // Local Includes
8 #include "portalevent.h"
9 
10 // External Includes
11 #include <nap/service.h>
12 #include <websocketservice.h>
13 #include <mutex>
14 
15 namespace nap
16 {
17  // Forward Declares
18  class PortalWebSocketServer;
19  class PortalComponentInstance;
20 
25  class NAPAPI PortalService : public Service
26  {
27  friend class PortalWebSocketServer;
29  RTTI_ENABLE(Service)
30 
31  public:
35  PortalService(ServiceConfiguration* configuration);
36 
40  WebSocketService& getWebSocketService();
41 
45  const WebSocketService& getWebSocketService() const;
46 
47  protected:
52  virtual void registerObjectCreators(rtti::Factory& factory) override;
53 
57  virtual void getDependentServices(std::vector<rtti::TypeInfo>& dependencies) override;
58 
62  virtual void created() override;
63 
70  virtual void update(double deltaTime) override;
71 
72  private:
73 
79  void processEvent(PortalEvent& event, PortalWebSocketServer& server);
80 
85  void registerServer(PortalWebSocketServer& server);
86 
91  void removeServer(PortalWebSocketServer& server);
92 
97  void registerComponent(PortalComponentInstance& component);
98 
103  void removeComponent(PortalComponentInstance& component);
104 
110  PortalComponentInstance* findComponentById(const std::string& id);
111 
112  // Handle to the WebSocket service
113  WebSocketService* mWebSocketService = nullptr;
114 
115  // All the portal WebSocket servers currently available to the system
116  std::vector<PortalWebSocketServer*> mServers;
117 
118  // All the portal components currently available to the system
119  std::vector<PortalComponentInstance*> mComponents;
120  };
121 }
nap::PortalService
Definition: portalservice.h:25
nap::WebSocketService
Definition: websocketservice.h:23
nap::PortalComponentInstance
Definition: portalcomponent.h:40
nap::ServiceConfiguration
Definition: service.h:28
nap::Service
Definition: templateservice.h:8
nap::PortalWebSocketServer
Definition: portalwebsocketserver.h:24
nap::rtti::Factory
Definition: factory.h:78
nap
Definition: templateapp.h:17
nap::PortalEvent
Definition: portalevent.h:26