|
Doxygen with github
|
A WebSocket server with authentication and text message handling. More...
#include <ksWSServer.h>
Classes | |
| class | Impl |
Public Member Functions | |
| ksWSServer (uint16_t port) | |
| Prepares ksWSServer on specified port without actually starting it. | |
| virtual | ~ksWSServer () |
| Destructs the server, releasing the resources. | |
| 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. | |
| bool | sendTXT (uint8_t client, const char *payload, std::size_t length=0) |
| Sends a text message to one client. A zero length uses a null-terminated payload. | |
| bool | broadcastTXT (const char *payload, std::size_t length=0) |
| Sends a text message to all clients. A zero length uses a null-terminated payload. | |
| void | enableHeartbeat (uint32_t pingInterval, uint32_t pongTimeout, uint8_t disconnectTimeoutCount) |
| Configures heartbeat intervals in milliseconds and the missed-pong limit. | |
A WebSocket server with authentication and text message handling.
| ksf::misc::ksWSServer::ksWSServer | ( | uint16_t | port | ) |
Prepares ksWSServer on specified port without actually starting it.
| port | Port to listen for incoming WebSocket connections. |
| 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).
| void ksf::misc::ksWSServer::setMessageHandler | ( | ksWsServerMessageFunc_t | func | ) |
Installs a message handler to receive WebSocket text messages.
| func | The message handler function. |
| 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. |