25 typedef std::function<void(uint8_t client, std::string_view message)> ksWsServerMessageFunc_t;
34 std::unique_ptr<Impl> impl;
88 bool sendTXT(uint8_t client,
const char* payload, std::size_t length = 0);
91 bool broadcastTXT(
const char* payload, std::size_t length = 0);
94 void enableHeartbeat(uint32_t pingInterval, uint32_t pongTimeout, uint8_t disconnectTimeoutCount);
Definition ksWSServer.cpp:18
A WebSocket server with authentication and text message handling.
Definition ksWSServer.h:31
virtual ~ksWSServer()
Destructs the server, releasing the resources.
void begin()
Starts the server.
Definition ksWSServer.cpp:145
void loop()
Handles WebSocket server logic.
Definition ksWSServer.cpp:150
ksWSServer(uint16_t port)
Prepares ksWSServer on specified port without actually starting it.
Definition ksWSServer.cpp:139
uint64_t getRequiredAuthToken() const
Returns simple authentication token for WebSocket authentication process.
Definition ksWSServer.cpp:155
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.
Definition ksWSServer.cpp:175
void setMessageHandler(ksWsServerMessageFunc_t func)
Installs a message handler to receive WebSocket text messages.
Definition ksWSServer.cpp:165
void enableHeartbeat(uint32_t pingInterval, uint32_t pongTimeout, uint8_t disconnectTimeoutCount)
Configures heartbeat intervals in milliseconds and the missed-pong limit.
Definition ksWSServer.cpp:180
void setRequiredAuthToken(uint64_t authToken)
Sets simple authtoken for WebSocket authentication.
Definition ksWSServer.cpp:160
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.
Definition ksWSServer.cpp:170