Class SseTransportProvider
Defined in File sse_transport_provider.hpp
Nested Relationships
Nested Types
Inheritance Relationships
Base Type
public ros2_medkit_gateway::SubscriptionTransportProvider(Class SubscriptionTransportProvider)
Class Documentation
-
class SseTransportProvider : public ros2_medkit_gateway::SubscriptionTransportProvider
Built-in SSE transport provider. Refactored from handle_events() logic.
Lifetime: must outlive all HTTP connections. GatewayNode ensures this by stopping the REST server (joining HTTP threads) before destroying transports.
Public Functions
-
inline virtual std::string protocol() const override
Protocol identifier: “sse” (standard), or vendor extension.
-
virtual tl::expected<std::string, std::string> start(const CyclicSubscriptionInfo &info, ResourceSamplerFn json_sampler, GatewayNode *node) override
Start delivery for a subscription. Returns event_source URI for client.
-
virtual void notify_update(const std::string &sub_id) override
Subscription interval/duration changed. Transport must re-read info.
-
virtual void stop(const std::string &sub_id) override
Stop delivery for a subscription.
For HTTP-based transports (SSE), the HTTP server thread join handles synchronous stop - stop() removes state so the streaming loop exits on its next is_active() check. GatewayNode::~GatewayNode() calls stop_rest_server() before shutdown_all() to ensure this ordering.
Non-HTTP transports MUST ensure all delivery threads have stopped before returning from this method.
-
virtual tl::expected<http::SseStream, ErrorInfo> make_sse_stream(const std::string &sub_id) override
Open a new client stream for the given subscription. HTTP-based transports (SSE) build an
whosenext_eventcallback the typed router drives via cpp-httplib’s chunked content provider. Non-HTTP transports (MQTT, WebSocket, Zenoh) return anErrorInfoso the typed handler renders a SOVD GenericError.On failure (unknown sub_id, client-limit exhausted, …) the implementation returns a fully-formed
ErrorInfowhosehttp_statusdrives the wire status code. On success the returnedSseStream’s lifetime owns the transport-side client-tracker handle (e.g. via a shared_ptr deleter on a captured tracker token) so the slot is released when the framework destroys the stream - either on client disconnect or end-of-stream.
-
inline virtual std::string protocol() const override