pub struct EventRouter { /* private fields */ }Expand description
Routes events from HTTP callbacks to a channel.
The EventRouter maintains a set of active subscription IDs. When an event
is received via HTTP callback, the router checks if the subscription is
registered and sends the notification payload to the configured channel.
Events for unregistered SIDs are buffered briefly and replayed when
register() is called, preventing the race between SUBSCRIBE response
and initial UPnP NOTIFY delivery.
Implementations§
Source§impl EventRouter
impl EventRouter
Sourcepub fn new(event_sender: UnboundedSender<NotificationPayload>) -> Self
pub fn new(event_sender: UnboundedSender<NotificationPayload>) -> Self
Sourcepub async fn register(&self, subscription_id: String)
pub async fn register(&self, subscription_id: String)
Register a subscription ID for event routing.
Adds the SID to the active set and replays any buffered events that
arrived before registration (the SUBSCRIBE/NOTIFY race window).
Also cleans up stale buffer entries older than BUFFER_TTL.
Sourcepub async fn unregister(&self, subscription_id: &str)
pub async fn unregister(&self, subscription_id: &str)
Unregister a subscription ID.
Removes the SID from the active set and drains any buffered events for it, preventing stale replays on future re-registration.
Sourcepub async fn route_event(&self, subscription_id: String, event_xml: String)
pub async fn route_event(&self, subscription_id: String, event_xml: String)
Route an incoming event to the unified event stream.
If the subscription is registered, the event is sent immediately.
If not, the event is buffered for replay when register() is called.
The caller should always return HTTP 200 OK — buffered events are
accepted for processing, not rejected.
Trait Implementations§
Source§impl Clone for EventRouter
impl Clone for EventRouter
Source§fn clone(&self) -> EventRouter
fn clone(&self) -> EventRouter
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more