NAP
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
IWebSocketServer Class Referenceabstract

#include <websocketserver.h>

Public Member Functions

 IWebSocketServer (WebSocketService &service)
 
virtual bool init (utility::ErrorState &errorState) override
 
virtual void onDestroy () override
 
- 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

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...
 

Protected Member Functions

virtual void onMessageReceived (const WebSocketConnection &connection, const WebSocketMessage &message)=0
 
virtual void onConnectionOpened (const WebSocketConnection &connection)=0
 
virtual void onConnectionClosed (const WebSocketConnection &connection, int code, const std::string &reason)=0
 
virtual void onConnectionFailed (const WebSocketConnection &connection, int code, const std::string &reason)=0
 
- Protected Member Functions inherited from WebSocketInterface
void addEvent (WebSocketEventPtr newEvent)
 

Additional Inherited Members

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

Description

Interface for all web-socket servers. Derive from this class to implement your own web-socket server. On initialization the client registers itself with a nap::WebSocketClientEndPointBase.

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

Constructor & Destructor Documentation

◆ IWebSocketServer()

Constructor

Parameters
servicethe web-socket service that forwards events to the application.

Member Function Documentation

◆ init()

virtual bool init ( utility::ErrorState errorState)
overridevirtual

Registers the web-socket server interface with the endpoint.

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

Reimplemented from WebSocketInterface.

Reimplemented in PortalWebSocketServer.

◆ onConnectionClosed()

virtual void onConnectionClosed ( const WebSocketConnection connection,
int  code,
const std::string &  reason 
)
protectedpure virtual

◆ onConnectionFailed()

virtual void onConnectionFailed ( const WebSocketConnection connection,
int  code,
const std::string &  reason 
)
protectedpure virtual

◆ onConnectionOpened()

virtual void onConnectionOpened ( const WebSocketConnection connection)
protectedpure virtual

◆ onDestroy()

virtual void onDestroy ( )
overridevirtual

Unregisters the web-socket server interface with the endpoint.

Reimplemented from Object.

Reimplemented in PortalWebSocketServer.

◆ onMessageReceived()

virtual void onMessageReceived ( const WebSocketConnection connection,
const WebSocketMessage message 
)
protectedpure virtual

Member Data Documentation

◆ mEndPoint

Property: 'EndPoint' the server endpoint that manages all client connections.