xmpp-rs/src/plugins/stanza_debug.rs
2017-05-27 17:22:53 +01:00

29 lines
785 B
Rust
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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,
]);