stanza_debug.rs

 1use plugin::PluginProxy;
 2use event::{SendElement, ReceiveElement, Propagation, Priority};
 3use chrono::Local;
 4
 5pub struct StanzaDebugPlugin {
 6    proxy: PluginProxy,
 7}
 8
 9impl StanzaDebugPlugin {
10    pub fn new() -> StanzaDebugPlugin {
11        StanzaDebugPlugin {
12            proxy: PluginProxy::new(),
13        }
14    }
15
16    fn handle_send_element(&self, evt: &SendElement) -> Propagation {
17        println!("{} SEND: {:?}", Local::now(), evt.0);
18        Propagation::Continue
19    }
20
21    fn handle_receive_element(&self, evt: &ReceiveElement) -> Propagation {
22        println!("{} RECV: {:?}", Local::now(), evt.0);
23        Propagation::Continue
24    }
25}
26
27impl_plugin!(StanzaDebugPlugin, proxy, [
28    (SendElement, Priority::Min) => handle_send_element,
29    (ReceiveElement, Priority::Max) => handle_receive_element,
30]);