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
10acdf1e78
commit
3225c1c7d1
2 changed files with 19 additions and 9 deletions
|
@ -28,6 +28,24 @@ pub struct Agent<C: ServerConnector> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: ServerConnector> Agent<C> {
|
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> {
|
pub async fn disconnect(&mut self) -> Result<(), Error> {
|
||||||
self.client.send_end().await
|
self.client.send_end().await
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,14 +156,6 @@ impl<C: ServerConnector> ClientBuilder<'_, C> {
|
||||||
let disco = self.make_disco();
|
let disco = self.make_disco();
|
||||||
let node = self.website;
|
let node = self.website;
|
||||||
|
|
||||||
Agent {
|
Agent::new(client, default_nick, lang, disco, node)
|
||||||
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,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue