|
oveRTOS C++ API
C++20 RAII wrappers for the oveRTOS C API
|
C++ wrappers around the oveRTOS WebSocket API. More...
Classes | |
| class | Connection |
| Non-owning handle to an active WebSocket connection. More... | |
Typedefs | |
| using | Handler = ove_httpd_ws_handler_t |
| WebSocket message handler type. | |
| using | CloseHandler = ove_httpd_ws_close_handler_t |
| WebSocket close handler type. | |
Functions | |
| Result< void > | route (const char *path, Handler on_message, CloseHandler on_close=nullptr) noexcept |
| Register a WebSocket route. | |
| int | broadcast (const char *path, const void *data, size_t len) |
| Broadcast a message to all WebSocket connections on a path. | |
| int | broadcast (const char *path, std::string_view sv) |
| Broadcast a string_view to all connections on a path. | |
| int | active_count () |
| Return the number of active WebSocket connections. | |
C++ wrappers around the oveRTOS WebSocket API.
Available when CONFIG_OVE_NET_HTTPD_WS is enabled.
|
inlinenoexcept |
Register a WebSocket route.
| [in] | path | URL path prefix (e.g. "/ws/log"). |
| [in] | on_message | Callback for incoming messages. |
| [in] | on_close | Callback when connection closes (may be nullptr). |
Result<void> on success; unexpected Error::NoMemory if the route table is full.
|
inline |
Broadcast a message to all WebSocket connections on a path.
| [in] | path | Path filter (nullptr for all connections). |
| [in] | data | Message payload. |
| [in] | len | Payload length in bytes. |
|
inline |
Broadcast a string_view to all connections on a path.
| [in] | path | Path filter (nullptr for all connections). |
| [in] | sv | String view to send. |