mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
update messaging plugin to support sending messages, still not sure how i'm going to modify the plugin architecture, so stays very unstable for now
This commit is contained in:
parent
142c6f0887
commit
83839f0ba6
1 changed files with 14 additions and 3 deletions
|
@ -1,14 +1,15 @@
|
|||
use plugin::{Plugin, PluginReturn, PluginProxy};
|
||||
use event::Event;
|
||||
use minidom::Element;
|
||||
use error::Error;
|
||||
use jid::Jid;
|
||||
use ns;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct MessageEvent {
|
||||
from: Jid,
|
||||
to: Jid,
|
||||
body: String,
|
||||
pub from: Jid,
|
||||
pub to: Jid,
|
||||
pub body: String,
|
||||
}
|
||||
|
||||
impl Event for MessageEvent {}
|
||||
|
@ -23,6 +24,16 @@ impl MessagingPlugin {
|
|||
proxy: PluginProxy::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn send_message(&self, to: &Jid, body: &str) -> Result<(), Error> {
|
||||
let mut elem = Element::builder("message")
|
||||
.attr("type", "chat")
|
||||
.attr("to", to.to_string())
|
||||
.build();
|
||||
elem.append_child(Element::builder("body").text(body).build());
|
||||
self.proxy.send(elem);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Plugin for MessagingPlugin {
|
||||
|
|
Loading…
Reference in a new issue