emit

Function emit 

Source
pub fn emit(key: impl Into<String>)
Expand description

Emit an event from the node. This is part of the metric API and allows you to collect information about when the nodes reach a certain point in the simulation, hence using the same key is not supported.

ยงPanics

If the event has already been emitted on the same node.

Examples found in repository?
examples/broadcast.rs (line 31)
29    fn handle_message_internal(&mut self, id: usize, payload: Vec<u8>) {
30        if self.messages.insert(id, payload.clone()).is_none() {
31            api::emit(String::from_utf8(payload).unwrap());
32        }
33
34        for (_addr, conn) in self.conns.iter_mut() {
35            if conn.seen.contains(&id) {
36                continue;
37            }
38
39            conn.writer.write(&Message::Advr(id));
40        }
41    }