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

#include <websocketserverendpoint.h>

Public Types

enum  ETLSMode : nap::uint8 { Intermediate = 0, Modern }
 

Public Member Functions

bool init (utility::ErrorState &errorState) override
 
bool start (nap::utility::ErrorState &error) override
 
- Public Member Functions inherited from WebSocketServerEndPointSetup< wspp::ConfigTLS >
 ~WebSocketServerEndPointSetup () override
 
bool init (utility::ErrorState &errorState) override
 
bool start (nap::utility::ErrorState &error) override
 
bool isOpen () const override
 
void stop () 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
 
bool broadcast (const std::string &message, EWebSocketOPCode code, nap::utility::ErrorState &error) override
 
bool broadcast (void const *payload, int length, EWebSocketOPCode code, nap::utility::ErrorState &error) override
 
std::string getHostName (const WebSocketConnection &connection) override
 
void getHostNames (std::vector< std::string > &outHosts) override
 
int getConnectionCount () override
 
bool acceptsNewConnections () override
 

Public Attributes

ETLSMode mMode = ETLSMode::Intermediate
 Property: "Mode" TLS configuration mode. More...
 
std::string mCertificateFile
 Property: "CertificateFile" TLS certificate file (.pem) More...
 
std::string mPrivateKeyFile
 Property: "PrivateKeyFile" TLS private key file (.key) More...
 
std::string mPassphrase
 Property: "Passphrase" password for the private key, only required when key is generated with one. More...
 

Additional Inherited Members

- Protected Member Functions inherited from WebSocketServerEndPointSetup< wspp::ConfigTLS >
void registerListener (IWebSocketServer &server) override
 
void unregisterListener (IWebSocketServer &server) override
 
void run ()
 
void onConnectionOpened (wspp::ConnectionHandle connection)
 
void onConnectionClosed (wspp::ConnectionHandle connection)
 
void onConnectionFailed (wspp::ConnectionHandle connection)
 
void onMessageReceived (wspp::ConnectionHandle con, wspp::MessagePtr msg)
 
void onHTTP (wspp::ConnectionHandle con)
 
bool onValidate (wspp::ConnectionHandle con)
 
bool onPing (wspp::ConnectionHandle con, std::string msg)
 
bool disconnect (nap::utility::ErrorState &error)
 
- Protected Attributes inherited from WebSocketServerEndPointSetup< wspp::ConfigTLS >
bool mRunning
 If the server is accepting and managing client connections. More...
 
std::mutex mConnectionMutex
 Ensures connections are added / removed safely. More...
 
std::unordered_set< WebSocketTicketHashmClientHashes
 Accepted client ticket hashes. More...
 
websocketpp::server< wspp::ConfigTLSmEndPoint
 The websocketpp server end-point. More...
 
uint32 mLogLevel
 Converted library log level. More...
 
uint32 mAccessLogLevel
 Log client / server connection data. More...
 
std::future< void > mServerTask
 The background server thread. More...
 
std::vector< wspp::ConnectionHandlemConnections
 List of all low level connections. More...
 
std::mutex mListenerMutex
 Ensures registration is thread safe. More...
 
std::vector< IWebSocketServer * > mListeners
 All registered web socket servers. More...
 

Description

Secured web-socket server end point connection. Adds transport layer security (TLS) using the provided certificate and key.

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

Member Enumeration Documentation

◆ ETLSMode

enum ETLSMode : nap::uint8
strong

Transport layer security (TLS) mode. See https://wiki.mozilla.org/Security/Server_Side_TLS for more details about the TLS modes.

Enumerator
Intermediate 

Recommended config for general-purpose server.

Modern 

For modern clients with no need for backwards compatibility.

Member Function Documentation

◆ init()

bool init ( utility::ErrorState errorState)
override

Initializes the server endpoint.

Parameters
errorStatecontains the error when initialization fails
Returns
if initialization succeeded

◆ start()

bool start ( nap::utility::ErrorState error)
override

Opens the port and starts listening to connection requests, connection updates and messages in a background thread.

Parameters
errorcontains the error if the operation failed.
Returns
if the endpoint started successfully.

Member Data Documentation

◆ mCertificateFile

std::string mCertificateFile

Property: "CertificateFile" TLS certificate file (.pem)

◆ mMode

Property: "Mode" TLS configuration mode.

◆ mPassphrase

std::string mPassphrase

Property: "Passphrase" password for the private key, only required when key is generated with one.

◆ mPrivateKeyFile

std::string mPrivateKeyFile

Property: "PrivateKeyFile" TLS private key file (.key)