ESPectre SDK 2.8.0-280-gac7af68
Wi-Fi CSI motion sensing for ESP32 firmware
Loading...
Searching...
No Matches
espectre::IDirectWebSocketService Class Referenceabstract

Local WebSocket endpoint used by the Native frontend after Wi-Fi is ready. More...

#include <direct_websocket_service.h>

Public Types

using RequestHandler = std::function<std::string(const DirectWebSocketRequest &request)>
using ClientCountCallback = std::function<void(size_t client_count)>

Public Member Functions

virtual ~IDirectWebSocketService ()=default
virtual bool setup (const DirectWebSocketServiceConfig &config, RequestHandler request_handler, ClientCountCallback client_count_callback)=0
 Configure and start the endpoint.
virtual void loop ()=0
 Pump deferred receive, dispatch, and send work from the frontend task.
virtual void shutdown ()=0
 Stop accepting clients, close sockets, and release queued messages.
virtual bool running () const =0
virtual size_t client_count () const =0
virtual bool publish_event (const std::string &event_name, const std::string &data_json, bool replaceable_telemetry)=0
 Queue a normalized event for every connected client.
virtual DirectWebSocketServiceDiagnostics diagnostics () const =0

Detailed Description

Local WebSocket endpoint used by the Native frontend after Wi-Fi is ready.

Definition at line 47 of file direct_websocket_service.h.

Member Typedef Documentation

◆ RequestHandler

using espectre::IDirectWebSocketService::RequestHandler = std::function<std::string(const DirectWebSocketRequest &request)>

Definition at line 49 of file direct_websocket_service.h.

◆ ClientCountCallback

Definition at line 50 of file direct_websocket_service.h.

Constructor & Destructor Documentation

◆ ~IDirectWebSocketService()

virtual espectre::IDirectWebSocketService::~IDirectWebSocketService ( )
virtualdefault

Member Function Documentation

◆ setup()

virtual bool espectre::IDirectWebSocketService::setup ( const DirectWebSocketServiceConfig & config,
RequestHandler request_handler,
ClientCountCallback client_count_callback )
pure virtual

Configure and start the endpoint.

Safe to call again after shutdown.

◆ loop()

virtual void espectre::IDirectWebSocketService::loop ( )
pure virtual

Pump deferred receive, dispatch, and send work from the frontend task.

◆ shutdown()

virtual void espectre::IDirectWebSocketService::shutdown ( )
pure virtual

Stop accepting clients, close sockets, and release queued messages.

◆ running()

virtual bool espectre::IDirectWebSocketService::running ( ) const
pure virtual

◆ client_count()

virtual size_t espectre::IDirectWebSocketService::client_count ( ) const
pure virtual

◆ publish_event()

virtual bool espectre::IDirectWebSocketService::publish_event ( const std::string & event_name,
const std::string & data_json,
bool replaceable_telemetry )
pure virtual

Queue a normalized event for every connected client.

Telemetry events may replace an older queued event with the same name. State transitions and command responses must never be replaced by telemetry. Returns false when no client can accept the event.

◆ diagnostics()

virtual DirectWebSocketServiceDiagnostics espectre::IDirectWebSocketService::diagnostics ( ) const
pure virtual

The documentation for this class was generated from the following file: