NAP
Public Member Functions | Public Attributes | List of all members
PortalWebSocketServer Class Reference

#include </opt/build/repo/nap/system_modules/napportal/src/portalwebsocketserver.h>

Public Member Functions

 PortalWebSocketServer (PortalService &service)
 
virtual bool init (utility::ErrorState &error) override
 
virtual void onDestroy () override
 
bool send (PortalEventPtr event, const WebSocketConnection &connection, utility::ErrorState &error)
 
bool broadcast (PortalEventPtr event, utility::ErrorState &error)
 
- Public Member Functions inherited from IWebSocketServer
 IWebSocketServer (WebSocketService &service)
 
- Public Member Functions inherited from WebSocketInterface
 WebSocketInterface (WebSocketService &service)
 
virtual ~WebSocketInterface ()
 
template<typename T >
T & as ()
 
template<typename T >
const T & as () const
 
- Public Member Functions inherited from Resource
 Resource ()
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
 Object (Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&)=delete
 
Objectoperator= (Object &&)=delete
 

Public Attributes

bool mSendWebSocketEvents = true
 Property: 'SendWebSocketEvents' send events to WebSocket service as well as portal service. More...
 
bool mVerbose = true
 Property: 'Verbose' log server message to portal event conversion failures. More...
 
- Public Attributes inherited from IWebSocketServer
ResourcePtr< IWebSocketServerEndPointmEndPoint
 Property: 'EndPoint' the server endpoint that manages all client connections. More...
 
- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 
- Protected Member Functions inherited from WebSocketInterface
void addEvent (WebSocketEventPtr newEvent)
 
- Protected Attributes inherited from WebSocketInterface
std::queue< WebSocketEventPtrmEvents
 
std::mutex mEventMutex
 
WebSocketServicemService = nullptr
 

Description

Portal WebSocket server implementation for sending and receiving API messages formatted as portal events. Implements the IWebSocketServer interface.

Inheritance diagram for PortalWebSocketServer:
[legend]
Collaboration diagram for PortalWebSocketServer:
[legend]

Constructor & Destructor Documentation

◆ PortalWebSocketServer()

Constructor

Parameters
servicehandle to the portal service

Member Function Documentation

◆ broadcast()

bool broadcast ( PortalEventPtr  event,
utility::ErrorState error 
)

Broadcasts a portal event to all connected clients.

Parameters
eventthe portal event to broadcast to the clients
errorcontains the error if broadcasting fails
Returns
if the message was broadcast successfully

◆ init()

virtual bool init ( utility::ErrorState error)
overridevirtual

Registers the portal WebSocket server with the portal service.

Parameters
errorcontains the error if initialization fails.
Returns
if initialization succeeded.

Reimplemented from IWebSocketServer.

◆ onDestroy()

virtual void onDestroy ( )
overridevirtual

Unregisters the portal WebSocket server with the portal service.

Reimplemented from IWebSocketServer.

◆ send()

bool send ( PortalEventPtr  event,
const WebSocketConnection connection,
utility::ErrorState error 
)

Sends a portal event to a client.

Parameters
eventthe portal event to send to the client
connectionthe client connection handle
errorcontains the error if sending fails
Returns
if the message was sent successfully

Member Data Documentation

◆ mSendWebSocketEvents

bool mSendWebSocketEvents = true

Property: 'SendWebSocketEvents' send events to WebSocket service as well as portal service.

◆ mVerbose

bool mVerbose = true

Property: 'Verbose' log server message to portal event conversion failures.