3#include <uwebsockets/App.h>
10#include <unordered_set>
65 void publish(std::string topic, std::string json);
73 std::atomic<bool> running_{
false};
75 std::atomic<uWS::Loop*> loop_{
nullptr};
76 std::atomic<uWS::SSLApp*> app_{
nullptr};
77 std::unordered_set<uWS::WebSocket<true, true, WsData>*> connections_;
79 std::promise<bool> listenResult_;
WebSocket server — the single bidirectional connection between the PWA and the backend.
Definition ws_server.h:31
void broadcast(std::string json)
Sends a JSON message to all currently-connected WebSocket clients.
Definition ws_server.cc:53
~WebSocketServer()
Destructor. Calls stop() if the server is still running.
Definition ws_server.cc:13
void publish(std::string topic, std::string json)
Publishes a JSON message to the clients subscribed to topic (native uWS pub/sub).
Definition ws_server.cc:63
void stop()
Stops the server, closes the listen socket, and joins the thread. Idempotent.
Definition ws_server.cc:32
bool start()
Starts the server background thread and begins accepting connections.
Definition ws_server.cc:21
The whole config file. Top-level keys map to these members.
Definition config.h:100
Server configuration.
Definition ws_server.h:34
uint16_t port
TCP port to listen on (TLS).
Definition ws_server.h:35
std::string keyFile
Path to the TLS private key (PEM).
Definition ws_server.h:37
std::string certFile
Path to the TLS certificate (PEM).
Definition ws_server.h:36