xmpp: new Agent::new method
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
5ae38545e4
commit
4780f89604
3 changed files with 23 additions and 15 deletions
|
|
@ -21,6 +21,7 @@ XXXX-YY-ZZ [ RELEASER <admin@localhost> ]
|
|||
- Event::ChatMessageCorrection, Event::RoomMessageCorrection, and
|
||||
Event::RoomPrivateMessageCorrection signal XEP-0308 message corrections; they're
|
||||
not checked how old the corrected entry is, which has security concerns (!496)
|
||||
- Agent::new helper method.
|
||||
* Fixes:
|
||||
- Use tokio::sync::RwLock not std::sync::RwLock (!432)
|
||||
- Agent::wait_for_events now return Vec<Event> and sets inner tokio_xmpp Client
|
||||
|
|
|
|||
|
|
@ -33,6 +33,27 @@ pub struct Agent {
|
|||
}
|
||||
|
||||
impl Agent {
|
||||
pub fn new(
|
||||
client: TokioXmppClient,
|
||||
default_nick: RoomNick,
|
||||
lang: Vec<String>,
|
||||
disco: DiscoInfoResult,
|
||||
node: String,
|
||||
) -> Agent {
|
||||
Agent {
|
||||
client,
|
||||
default_nick: Arc::new(RwLock::new(default_nick)),
|
||||
lang: Arc::new(lang),
|
||||
disco,
|
||||
node,
|
||||
uploads: Vec::new(),
|
||||
awaiting_disco_bookmarks_type: false,
|
||||
rooms_joined: HashMap::new(),
|
||||
rooms_joining: HashMap::new(),
|
||||
rooms_leaving: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn disconnect(self) -> Result<(), Error> {
|
||||
self.client.send_end().await
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,10 +6,7 @@
|
|||
|
||||
#[cfg(any(feature = "starttls-rust", feature = "starttls-native"))]
|
||||
use crate::tokio_xmpp::connect::{DnsConfig, StartTlsServerConnector};
|
||||
use alloc::sync::Arc;
|
||||
use core::str::FromStr;
|
||||
use std::collections::HashMap;
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
use crate::{
|
||||
jid::{BareJid, Jid, ResourceRef},
|
||||
|
|
@ -172,17 +169,6 @@ impl<C: ServerConnector> ClientBuilder<'_, C> {
|
|||
let disco = self.make_disco();
|
||||
let node = self.website;
|
||||
|
||||
Agent {
|
||||
client,
|
||||
default_nick: Arc::new(RwLock::new(self.default_nick)),
|
||||
lang: Arc::new(self.lang),
|
||||
disco,
|
||||
node,
|
||||
uploads: Vec::new(),
|
||||
awaiting_disco_bookmarks_type: false,
|
||||
rooms_joined: HashMap::new(),
|
||||
rooms_joining: HashMap::new(),
|
||||
rooms_leaving: HashMap::new(),
|
||||
}
|
||||
Agent::new(client, self.default_nick, self.lang, disco, node)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue