dbus_async/connection/message/
signal.rs

1use super::super::Connection;
2use dbus_message_parser::message::Message;
3use retain_mut::RetainMut;
4
5impl Connection {
6    pub(super) fn signal(&mut self, msg: Message) {
7        // It is a Signal so we have to get the Path first.
8        let path = msg.get_path().unwrap();
9        // Try to get the signal handler
10        if let Some(list) = self.signals.get_mut(path) {
11            // Go through the list and try to send the signal.
12            list.retain_mut(move |(filter, sender)| {
13                if let Some(filter) = filter {
14                    if filter(&msg) {
15                        return true;
16                    }
17                }
18                if let Err(e) = sender.try_send(msg.clone()) {
19                    if e.is_disconnected() {
20                        // The handler is closed so remove it from the list.
21                        return false;
22                    }
23                }
24                true
25            });
26        } else {
27            debug!("Signal: UNHANDLED: {:?}", msg);
28        }
29    }
30}