add a stanza_debug plugin, printing every stanza on stdout

This commit is contained in:
Emmanuel Gil Peyrot 2017-05-27 17:19:28 +01:00
parent ac7c907e9f
commit 66bf10b941
2 changed files with 30 additions and 0 deletions

View file

@ -2,3 +2,4 @@ pub mod messaging;
pub mod presence;
pub mod ping;
pub mod stanza;
pub mod stanza_debug;

View file

@ -0,0 +1,29 @@
use plugin::PluginProxy;
use event::{SendElement, ReceiveElement, Propagation, Priority};
pub struct StanzaDebugPlugin {
proxy: PluginProxy,
}
impl StanzaDebugPlugin {
pub fn new() -> StanzaDebugPlugin {
StanzaDebugPlugin {
proxy: PluginProxy::new(),
}
}
fn handle_send_element(&self, evt: &SendElement) -> Propagation {
println!("SEND: {:?}", evt.0);
Propagation::Continue
}
fn handle_receive_element(&self, evt: &ReceiveElement) -> Propagation {
println!("RECV: {:?}", evt.0);
Propagation::Continue
}
}
impl_plugin!(StanzaDebugPlugin, proxy, [
(SendElement, Priority::Min) => handle_send_element,
(ReceiveElement, Priority::Max) => handle_receive_element,
]);