Merge branch 'stanza-debug' into 'master'
Add a stanza_debug plugin See merge request !10
This commit is contained in:
commit
b2a18f8e3e
4 changed files with 32 additions and 2 deletions
|
@ -2,3 +2,4 @@ pub mod messaging;
|
|||
pub mod presence;
|
||||
pub mod ping;
|
||||
pub mod stanza;
|
||||
pub mod stanza_debug;
|
||||
|
|
|
@ -51,7 +51,7 @@ impl PingPlugin {
|
|||
});
|
||||
}
|
||||
}
|
||||
Propagation::Continue
|
||||
Propagation::Stop
|
||||
}
|
||||
|
||||
fn reply_ping(&self, ping: &PingEvent) -> Propagation {
|
||||
|
|
|
@ -40,7 +40,7 @@ impl StanzaPlugin {
|
|||
self.proxy.dispatch(iq);
|
||||
}
|
||||
|
||||
Propagation::Continue
|
||||
Propagation::Stop
|
||||
}
|
||||
}
|
||||
|
||||
|
|
29
src/plugins/stanza_debug.rs
Normal file
29
src/plugins/stanza_debug.rs
Normal 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!("[36;1mSEND[0m: {:?}", evt.0);
|
||||
Propagation::Continue
|
||||
}
|
||||
|
||||
fn handle_receive_element(&self, evt: &ReceiveElement) -> Propagation {
|
||||
println!("[33;1mRECV[0m: {:?}", evt.0);
|
||||
Propagation::Continue
|
||||
}
|
||||
}
|
||||
|
||||
impl_plugin!(StanzaDebugPlugin, proxy, [
|
||||
(SendElement, Priority::Min) => handle_send_element,
|
||||
(ReceiveElement, Priority::Max) => handle_receive_element,
|
||||
]);
|
Loading…
Reference in a new issue