pub struct SubscriptionCache { /* private fields */ }Expand description
Structure storing all subscriptions and monitored items on the server. Used to notify users of changes.
Subscriptions can outlive sessions, and sessions can outlive connections, so neither can be owned by the connection. This provides convenient methods for manipulating subscriptions.
Implementations§
Source§impl SubscriptionCache
impl SubscriptionCache
Sourcepub fn get_session_subscriptions(
&self,
session_id: u32,
) -> Option<Arc<Mutex<SessionSubscriptions>>>
pub fn get_session_subscriptions( &self, session_id: u32, ) -> Option<Arc<Mutex<SessionSubscriptions>>>
Get the SessionSubscriptions object for a single session by its numeric ID.
Sourcepub fn data_notifier<'a>(&'a self) -> SubscriptionDataNotifier<'a>
pub fn data_notifier<'a>(&'a self) -> SubscriptionDataNotifier<'a>
Return a notifier for notifying the server of a batch of changes.
Note: This contains a lock, and should not be kept around for long periods of time, or held over await points.
The notifier submits notifications only once dropped.
§Example
let mut notifier = cache.data_notifier();
for (node_id, data_value) in my_changes {
notifier.notify(node_id, AttributeId::Value, value);
}Sourcepub fn event_notifier<'a, 'b>(&'a self) -> SubscriptionEventNotifier<'a, 'b>
pub fn event_notifier<'a, 'b>(&'a self) -> SubscriptionEventNotifier<'a, 'b>
Return a notifier for notifying the server of a batch of events.
Note: This contains a lock, and should not be kept around for long periods of time, or held over await points.
The notifier submits notifications only once dropped.
§Example
let mut notifier = cache.event_notifier();
for evt in my_evts {
notifier.notify(emitter_id, evt);
}Sourcepub fn notify_data_change<'a>(
&self,
items: impl Iterator<Item = (DataValue, &'a NodeId, AttributeId)>,
)
pub fn notify_data_change<'a>( &self, items: impl Iterator<Item = (DataValue, &'a NodeId, AttributeId)>, )
Notify any listening clients about a list of data changes. This can be called any time anything changes on the server, or only for values with an existing monitored item. Either way this method will deal with distributing the values to the appropriate monitored items.
Sourcepub fn maybe_notify<'a>(
&self,
items: impl Iterator<Item = (&'a NodeId, AttributeId)>,
sample: impl Fn(&NodeId, AttributeId, &NumericRange, &DataEncoding) -> Option<DataValue>,
)
pub fn maybe_notify<'a>( &self, items: impl Iterator<Item = (&'a NodeId, AttributeId)>, sample: impl Fn(&NodeId, AttributeId, &NumericRange, &DataEncoding) -> Option<DataValue>, )
Notify with a dynamic sampler, to avoid getting values for nodes that may not have monitored items. This is potentially much more efficient than simply notifying blindly, but is also somewhat harder to use.
Sourcepub fn notify_events<'a>(
&self,
items: impl Iterator<Item = (&'a dyn Event, &'a NodeId)>,
)
pub fn notify_events<'a>( &self, items: impl Iterator<Item = (&'a dyn Event, &'a NodeId)>, )
Notify listening clients to events. Without a custom node manager implementing event history, this is the only way to report events in the server.