pub struct SubscriptionManager { /* private fields */ }Expand description
Subscription manager for tracking resource subscriptions
Thread-safe structure that maps resource URIs to subscribed sessions and sessions to their subscribed URIs.
Implementations§
Source§impl SubscriptionManager
impl SubscriptionManager
Sourcepub fn with_notifications(
notification_tx: UnboundedSender<JsonRpcNotification>,
) -> Self
pub fn with_notifications( notification_tx: UnboundedSender<JsonRpcNotification>, ) -> Self
Create subscription manager with a global notification channel
Sourcepub fn register_session_notifier(
&self,
session_id: &str,
tx: UnboundedSender<JsonRpcNotification>,
)
pub fn register_session_notifier( &self, session_id: &str, tx: UnboundedSender<JsonRpcNotification>, )
Register a per-session notification channel
This allows targeted notifications to specific sessions rather than broadcasting to all.
Sourcepub fn unregister_session_notifier(&self, session_id: &str)
pub fn unregister_session_notifier(&self, session_id: &str)
Unregister a session’s notification channel
Sourcepub fn subscribe(&self, session_id: &str, uri: &str) -> bool
pub fn subscribe(&self, session_id: &str, uri: &str) -> bool
Subscribe a session to a resource URI
Returns true if this is a new subscription, false if already subscribed.
Sourcepub fn unsubscribe(&self, session_id: &str, uri: &str) -> bool
pub fn unsubscribe(&self, session_id: &str, uri: &str) -> bool
Unsubscribe a session from a resource URI
Returns true if subscription existed and was removed.
Sourcepub fn remove_session(&self, session_id: &str)
pub fn remove_session(&self, session_id: &str)
Remove all subscriptions for a session
Call this when a session closes to clean up all its subscriptions.
Sourcepub fn is_subscribed(&self, session_id: &str, uri: &str) -> bool
pub fn is_subscribed(&self, session_id: &str, uri: &str) -> bool
Check if a session is subscribed to a URI
Sourcepub fn get_subscribers(&self, uri: &str) -> Vec<String>
pub fn get_subscribers(&self, uri: &str) -> Vec<String>
Get all sessions subscribed to a URI
Sourcepub fn get_session_subscriptions(&self, session_id: &str) -> Vec<String>
pub fn get_session_subscriptions(&self, session_id: &str) -> Vec<String>
Get all URIs a session is subscribed to
Sourcepub fn subscription_count(&self) -> usize
pub fn subscription_count(&self) -> usize
Get total subscription count
Sourcepub fn subscribed_uri_count(&self) -> usize
pub fn subscribed_uri_count(&self) -> usize
Get count of unique URIs with subscribers
Sourcepub fn notify_resource_updated(&self, uri: &str)
pub fn notify_resource_updated(&self, uri: &str)
Notify all subscribers that a resource has been updated
Sends notifications/resources/updated to all sessions subscribed to the URI.
Sourcepub fn notify_resources_updated(&self, uris: &[&str])
pub fn notify_resources_updated(&self, uris: &[&str])
Notify subscribers for multiple URIs (batch operation)
Trait Implementations§
Source§impl Clone for SubscriptionManager
impl Clone for SubscriptionManager
Source§fn clone(&self) -> SubscriptionManager
fn clone(&self) -> SubscriptionManager
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more