2023-12-30 22:08:37 -05:00
|
|
|
use std::str::FromStr;
|
|
|
|
|
|
2024-07-24 20:39:27 +02:00
|
|
|
use xmpp_parsers::jid::Jid;
|
2023-12-30 22:08:37 -05:00
|
|
|
|
2024-08-03 15:17:27 +02:00
|
|
|
use crate::{Error, SimpleClient};
|
2023-12-30 22:08:37 -05:00
|
|
|
|
|
|
|
|
use super::ServerConfig;
|
|
|
|
|
|
|
|
|
|
impl SimpleClient<ServerConfig> {
|
|
|
|
|
/// Start a new XMPP client and wait for a usable session
|
|
|
|
|
pub async fn new<P: Into<String>>(jid: &str, password: P) -> Result<Self, Error> {
|
|
|
|
|
let jid = Jid::from_str(jid)?;
|
|
|
|
|
Self::new_with_jid(jid, password.into()).await
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Start a new client given that the JID is already parsed.
|
|
|
|
|
pub async fn new_with_jid(jid: Jid, password: String) -> Result<Self, Error> {
|
|
|
|
|
Self::new_with_jid_connector(ServerConfig::UseSrv, jid, password).await
|
|
|
|
|
}
|
|
|
|
|
}
|