mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
xmpp: Add Agent::new
For ease of use in coming changes Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
99036735a3
commit
320ef0781e
2 changed files with 19 additions and 9 deletions
|
@ -24,6 +24,24 @@ pub struct Agent<C: ServerConnector> {
|
|||
}
|
||||
|
||||
impl<C: ServerConnector> Agent<C> {
|
||||
async fn new(
|
||||
client: TokioXmppClient,
|
||||
default_nick: String,
|
||||
lang: String,
|
||||
diso: 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,
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn disconnect(&mut self) -> Result<(), Error> {
|
||||
self.client.send_end().await
|
||||
}
|
||||
|
|
|
@ -155,14 +155,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,
|
||||
}
|
||||
Agent::new(client, default_nick, lang, disco, node)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue