mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
Basic MUC plugin
This commit is contained in:
parent
fcaa29d9c2
commit
e953a03dda
2 changed files with 54 additions and 0 deletions
|
@ -8,3 +8,4 @@ pub mod ibb;
|
||||||
pub mod stanza;
|
pub mod stanza;
|
||||||
pub mod stanza_debug;
|
pub mod stanza_debug;
|
||||||
pub mod unhandled_iq;
|
pub mod unhandled_iq;
|
||||||
|
pub mod muc;
|
||||||
|
|
53
src/plugins/muc.rs
Normal file
53
src/plugins/muc.rs
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
|
use jid::Jid;
|
||||||
|
use error::Error;
|
||||||
|
use plugin::PluginProxy;
|
||||||
|
|
||||||
|
pub use xmpp_parsers::muc::Muc;
|
||||||
|
pub use xmpp_parsers::presence::{Presence, Type, Show};
|
||||||
|
|
||||||
|
pub struct MucPlugin {
|
||||||
|
proxy: PluginProxy,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MucPlugin {
|
||||||
|
pub fn new() -> MucPlugin {
|
||||||
|
MucPlugin {
|
||||||
|
proxy: PluginProxy::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn join_room(&self, room: Jid) -> Result<(), Error> {
|
||||||
|
let presence = Presence {
|
||||||
|
from: None,
|
||||||
|
to: Some(room),
|
||||||
|
id: None,
|
||||||
|
type_: Type::None,
|
||||||
|
show: Show::None,
|
||||||
|
priority: 0i8,
|
||||||
|
statuses: BTreeMap::new(),
|
||||||
|
payloads: vec![Muc.into()],
|
||||||
|
};
|
||||||
|
self.proxy.send(presence.into());
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn leave_room(&self, room: Jid) -> Result<(), Error> {
|
||||||
|
let presence = Presence {
|
||||||
|
from: None,
|
||||||
|
to: Some(room),
|
||||||
|
id: None,
|
||||||
|
type_: Type::None,
|
||||||
|
show: Show::None,
|
||||||
|
priority: 0i8,
|
||||||
|
statuses: BTreeMap::new(),
|
||||||
|
payloads: vec![Muc.into()],
|
||||||
|
};
|
||||||
|
self.proxy.send(presence.into());
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl_plugin!(MucPlugin, proxy, []);
|
Loading…
Reference in a new issue