Class SseTransportProvider

Nested Relationships

Nested Types

Inheritance Relationships

Base Type

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

SseTransportProvider(SubscriptionManager &sub_mgr, std::shared_ptr<SSEClientTracker> client_tracker)
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 bool handle_client_connect(const std::string &sub_id, const httplib::Request &req, httplib::Response &res) override

Handle HTTP client connection (SSE: chunked provider, WebSocket: upgrade). MQTT/Zenoh: return false (not HTTP-based).