3#include <uwebsockets/App.h>
10#include <unordered_set>
74 void publish(std::string topic, std::string json);
82 std::atomic<bool> running_{
false};
84 std::atomic<uWS::Loop*> loop_{
nullptr};
85 std::atomic<uWS::SSLApp*> app_{
nullptr};
86 std::unordered_set<uWS::WebSocket<true, true, WsData>*> connections_;
88 std::promise<bool> listenResult_;
WebSocket server — the single bidirectional connection between the PWA and the backend.
Definition ws_server.h:32
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:197
Server configuration.
Definition ws_server.h:35
uint16_t port
TCP port to listen on (TLS).
Definition ws_server.h:38
std::string bindAddress
Local address to bind. Loopback serves only this machine; "0.0.0.0" serves the network.
Definition ws_server.h:37
std::string keyFile
Path to the TLS private key (PEM).
Definition ws_server.h:40
std::string certFile
Path to the TLS certificate (PEM).
Definition ws_server.h:39