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:
Maxime “pep” Buquet 2024-01-01 15:23:32 +01:00
parent 99036735a3
commit 320ef0781e
2 changed files with 19 additions and 9 deletions

View file

@ -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
}

View file

@ -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)
}
}