NAP
websocketcomponent.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 "websocketinterface.h"
9 
10 // External Includes
11 #include <component.h>
12 #include <nap/signalslot.h>
13 #include <nap/resourceptr.h>
14 
15 namespace nap
16 {
17  // Forward Declares
18  class WebSocketComponentInstance;
19 
26  class NAPAPI WebSocketComponent : public Component
27  {
28  RTTI_ENABLE(Component)
30  public:
32  };
33 
34 
42  {
43  RTTI_ENABLE(ComponentInstance)
44  public:
51  ComponentInstance(entity, resource) { }
52 
53  // Destructor
54  virtual ~WebSocketComponentInstance();
55 
61  virtual bool init(utility::ErrorState& errorState) override;
62 
66  const WebSocketInterface& getInterface() const { return *mInterface; }
67 
71  WebSocketInterface& getInterface() { return *mInterface; }
72 
77 
82 
87 
92 
93  private:
94  WebSocketInterface* mInterface = nullptr;
95  WebSocketService* mService = nullptr;
96  };
97 }
nap::WebSocketComponentInstance::getInterface
WebSocketInterface & getInterface()
Definition: websocketcomponent.h:71
nap::WebSocketComponentInstance::connectionClosed
nap::Signal< const WebSocketConnectionClosedEvent & > connectionClosed
Definition: websocketcomponent.h:81
nap::rtti::ObjectPtr
Definition: objectptr.h:154
nap::WebSocketComponentInstance::getInterface
const WebSocketInterface & getInterface() const
Definition: websocketcomponent.h:66
nap::WebSocketService
Definition: websocketservice.h:23
nap::utility::ErrorState
Definition: errorstate.h:19
nap::WebSocketComponentInstance::connectionFailed
nap::Signal< const WebSocketConnectionFailedEvent & > connectionFailed
Definition: websocketcomponent.h:86
nap::WebSocketComponentInstance::connectionOpened
nap::Signal< const WebSocketConnectionOpenedEvent & > connectionOpened
Definition: websocketcomponent.h:76
nap::WebSocketComponentInstance::messageReceived
nap::Signal< const WebSocketMessageReceivedEvent & > messageReceived
Definition: websocketcomponent.h:91
nap::Signal
Definition: signalslot.h:28
nap::WebSocketComponent
Definition: websocketcomponent.h:26
nap::EntityInstance
Definition: entity.h:34
nap::ComponentInstance
Definition: component.h:43
nap::Component
Definition: component.h:151
nap::WebSocketComponentInstance::WebSocketComponentInstance
WebSocketComponentInstance(EntityInstance &entity, Component &resource)
Definition: websocketcomponent.h:50
nap::WebSocketComponentInstance
Definition: websocketcomponent.h:41
nap
Definition: templateapp.h:17
nap::WebSocketInterface
Definition: websocketinterface.h:28
nap::WebSocketComponent::mInterface
nap::ResourcePtr< WebSocketInterface > mInterface
Property: "Interface" the web-socket client or server this component listens to for events.
Definition: websocketcomponent.h:31