xmpp: new 'escape-hatch' feature
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
a8c66bc783
commit
477af3c895
3 changed files with 13 additions and 0 deletions
|
|
@ -35,6 +35,7 @@ default = ["avatars", "starttls-rust"]
|
|||
starttls-native = ["tokio-xmpp/starttls", "tokio-xmpp/tls-native", "reqwest/native-tls"]
|
||||
starttls-rust = ["tokio-xmpp/starttls", "tokio-xmpp/tls-rust", "reqwest/rustls-tls"]
|
||||
avatars = []
|
||||
escape-hatch = []
|
||||
syntax-highlighting = [ "tokio-xmpp/syntax-highlighting" ]
|
||||
# Enable serde support in jid crate
|
||||
serde = [ "tokio-xmpp/serde" ]
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@ XXXX-YY-ZZ [ RELEASER <admin@localhost> ]
|
|||
- Agent::new helper method.
|
||||
- Handle SIGINT, SIGTERM and SIGKILL in hello_bot example to avoid leaving
|
||||
hibernating resources around.
|
||||
- New 'escape-hatch' feature: Allow sending tokio_xmpp::Stanza directly
|
||||
instead of having to go through xmpp-rs' API when it's lacking. This
|
||||
is meant to stay behind a feature.
|
||||
* Fixes:
|
||||
- Use tokio::sync::RwLock not std::sync::RwLock (!432)
|
||||
- Agent::wait_for_events now return Vec<Event> and sets inner tokio_xmpp Client
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
use alloc::sync::Arc;
|
||||
use std::collections::HashMap;
|
||||
use std::path::{Path, PathBuf};
|
||||
#[cfg(feature = "escape-hatch")]
|
||||
use tokio::io;
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
use crate::{
|
||||
|
|
@ -17,6 +19,8 @@ use crate::{
|
|||
upload, Error, Event, RoomNick,
|
||||
};
|
||||
use tokio_xmpp::Client as TokioXmppClient;
|
||||
#[cfg(feature = "escape-hatch")]
|
||||
use tokio_xmpp::{stanzastream::StanzaToken, Stanza};
|
||||
|
||||
pub struct Agent {
|
||||
pub(crate) client: TokioXmppClient,
|
||||
|
|
@ -58,6 +62,11 @@ impl Agent {
|
|||
self.client.send_end().await
|
||||
}
|
||||
|
||||
#[cfg(feature = "escape-hatch")]
|
||||
pub async fn send_stanza<S: Into<Stanza>>(&mut self, st: S) -> Result<StanzaToken, io::Error> {
|
||||
self.client.send_stanza(st.into()).await
|
||||
}
|
||||
|
||||
pub async fn join_room<'a>(&mut self, settings: muc::room::JoinRoomSettings<'a>) {
|
||||
muc::room::join_room(self, settings).await
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue