Doxygen with github
|
Wrapper around WebSocketsServerCore that adds WebSocket authentication and better message handling. More...
#include <ksWSServer.h>
Public Member Functions | |
ksWSServer (uint16_t port) | |
Prepares ksWebServer on specified port without actually starting it. | |
uint64_t | getRequiredAuthToken () const |
Returns simple authentication token for WebSocket authentication process. | |
void | setRequiredAuthToken (uint64_t authToken) |
Sets simple authtoken for WebSocket authentication. | |
void | begin () |
Starts the server. | |
void | loop () |
Handles WebSocket server logic. | |
void | setMessageHandler (ksWsServerMessageFunc_t func) |
Installs a message handler to receive WebSocket text messages. | |
virtual | ~ksWSServer () |
Destructs the server, releasing the resources. | |
Protected Member Functions | |
void | handleNonWebsocketConnection (WSclient_t *client) override |
Handler for non-WebSocket connections on websocket port. | |
Wrapper around WebSocketsServerCore that adds WebSocket authentication and better message handling.
ksf::misc::ksWSServer::ksWSServer | ( | uint16_t | port | ) |
Prepares ksWebServer on specified port without actually starting it.
port | Port to listen for incoming WebSocket connections. |
References wsListener.
uint64_t ksf::misc::ksWSServer::getRequiredAuthToken | ( | ) | const |
Returns simple authentication token for WebSocket authentication process.
The value 0 is considered to be empty token. Authentication token is set via setRequiredAuthToken().
Generally, this token should be generated earlier, then the WebServer should use Cookie to transmit it to the browser and then the browser should pass it with WebSocket requests (via HTTP Cookie header).
References requriedAuthToken.
|
overrideprotected |
Handler for non-WebSocket connections on websocket port.
clientS | Pointer to the WSclient_t object. |
void ksf::misc::ksWSServer::setMessageHandler | ( | ksWsServerMessageFunc_t | func | ) |
Installs a message handler to receive WebSocket text messages.
func | The message handler function. |
References onWebsocketTextMessage.
void ksf::misc::ksWSServer::setRequiredAuthToken | ( | uint64_t | authToken | ) |
Sets simple authtoken for WebSocket authentication.
The value 0 is considered to be invalid (no auth token). Auth token is set via setRequiredAuthToken(). Generally, this token should be generated earlier, then the WebServer should use Cookie to transmit it to the browser and then the browser should pass it with WebSocket requests (via HTTP Cookie header).
authToken | The token to set. |
References requriedAuthToken.