#include <websocketclientendpoint.h>
Public Member Functions | |
virtual bool | init (utility::ErrorState &errorState) override |
virtual void | stop () override |
bool | start (nap::utility::ErrorState &error) override |
bool | send (const WebSocketConnection &connection, const std::string &message, EWebSocketOPCode code, nap::utility::ErrorState &error) override |
bool | send (const WebSocketConnection &connection, void const *payload, int length, EWebSocketOPCode code, nap::utility::ErrorState &error) override |
![]() | |
Resource () | |
![]() | |
Object () | |
virtual | ~Object () |
virtual void | onDestroy () |
Object (Object &)=delete | |
Object & | operator= (const Object &)=delete |
Object (Object &&)=delete | |
Object & | operator= (Object &&)=delete |
Protected Member Functions | |
void | run () |
bool | registerClient (IWebSocketClient &client, utility::ErrorState &error) override |
void | unregisterClient (const IWebSocketClient &client) override |
Protected Attributes | |
uint32 | mLogLevel = 0 |
Converted library log level. More... | |
uint32 | mAccessLogLevel = 0 |
Log client / server connection data. More... | |
bool | mRunning = false |
If the client connection to the server is open. More... | |
std::future< void > | mClientTask |
The client server thread. More... | |
std::vector< std::unique_ptr< WebSocketClientWrapper< config > > > | mClients |
All unique client connections. More... | |
websocketpp::client< config > | mEndPoint |
websocketpp client end point More... | |
Additional Inherited Members | |
![]() | |
static bool | isIDProperty (rtti::Instance &object, const rtti::Property &property) |
![]() | |
bool | mLogConnectionUpdates = true |
Property: "LogConnectionUpdates" if client / server connection information is logged to the console. More... | |
EWebSocketLogLevel | mLibraryLogLevel = EWebSocketLogLevel::Warning |
Property: "LibraryLogLevel" library related equal to or higher than requested are logged. More... | |
![]() | |
std::string | mID |
Property: 'mID' unique name of the object. Used as an identifier by the system. More... | |
Web socket client endpoint implementation using a specific configuration, where config
is the websocketpp (secured / unsecured) end-point configuration type.
Manages a list of client-server connections and acts as the main portal for the client to the server. Every web-socket client receives connection updates and messages from an endpoint. The endpoint is a device that can be started and stopped.
When stopped all active client-server connections are closed. This occurs when file changes are detected and the content of the application is hot-reloaded. Typically an application has only one endpoint. Multiple clients can reference the same endpoint. Every connection update and message is forwarded to the client from a background thread. To receive connection updates and messages a client must be dervied from nap::IWebSocketClient.
Note that depending on your operating system you might have to run the application as administrator
|
overridevirtual |
Initialize this object after de-serialization
errorState | contains the error message when initialization fails. |
Reimplemented from Object.
|
overrideprotectedvirtual |
Connects a nap client to a server. The new connection is managed by this endpoint. The client is added to the list of internally managed clients.
client | the client to register |
error | contains the error is registration fails. |
Implements IWebSocketClientEndPoint.
|
protected |
Runs the endpoint in a background thread until stopped.
|
overridevirtual |
Sends a message to a server.
connection | the client connection to the server. |
message | the message to send. |
code | type of message. |
error | contains the error if sending fails. |
Implements IWebSocketClientEndPoint.
|
overridevirtual |
Sends a message using the given payload and opcode to a server.
connection | the client connection to the server. |
payload | the message buffer. |
length | buffer size in bytes. |
code | type of message. |
error | contains the error if sending fails. |
Implements IWebSocketClientEndPoint.
|
overridevirtual |
Starts the endpoint. This is a non-blocking call. New connections are accepted. Connection updates and messages are received in a background thread.
error | contains the error if the endpoint can't be started. |
Reimplemented from Device.
|
overridevirtual |
Stops the endpoint. All active connections are closed.
Reimplemented from Device.
|
overrideprotectedvirtual |
Removes a client (resource) from the list of actively managed connection. If the client connection is currently open it will be closed. Asserts if the client isn't part of the system or can't be removed.
client | the client to remove. |
Implements IWebSocketClientEndPoint.
|
protected |
Log client / server connection data.
|
protected |
All unique client connections.
|
protected |
The client server thread.
|
protected |
websocketpp client end point
|
protected |
Converted library log level.
|
protected |
If the client connection to the server is open.