tokio_xmpp: implement high-level, resilient stanza stream
This commit is contained in:
parent
56ce57ecde
commit
80f899daa0
14 changed files with 2943 additions and 8 deletions
|
|
@ -103,14 +103,13 @@ pub async fn auth<S: AsyncBufRead + AsyncWrite + Unpin>(
|
|||
Err(AuthError::NoMechanism.into())
|
||||
}
|
||||
|
||||
/// Log into an XMPP server as a client with a jid+pass
|
||||
/// does channel binding if supported
|
||||
pub async fn client_login<C: ServerConnector>(
|
||||
/// Authenticate to an XMPP server, but do not bind a resource.
|
||||
pub async fn client_auth<C: ServerConnector>(
|
||||
server: C,
|
||||
jid: Jid,
|
||||
password: String,
|
||||
timeouts: Timeouts,
|
||||
) -> Result<(Option<FullJid>, StreamFeatures, XmppStream<C::Stream>), Error> {
|
||||
) -> Result<(StreamFeatures, XmppStream<C::Stream>), Error> {
|
||||
let username = jid.node().unwrap().as_str();
|
||||
let password = password;
|
||||
|
||||
|
|
@ -132,7 +131,18 @@ pub async fn client_login<C: ServerConnector>(
|
|||
id: None,
|
||||
})
|
||||
.await?;
|
||||
let (features, mut stream) = stream.recv_features().await?;
|
||||
Ok(stream.recv_features().await?)
|
||||
}
|
||||
|
||||
/// Log into an XMPP server as a client with a jid+pass
|
||||
/// does channel binding if supported
|
||||
pub async fn client_login<C: ServerConnector>(
|
||||
server: C,
|
||||
jid: Jid,
|
||||
password: String,
|
||||
timeouts: Timeouts,
|
||||
) -> Result<(Option<FullJid>, StreamFeatures, XmppStream<C::Stream>), Error> {
|
||||
let (features, mut stream) = client_auth(server, jid.clone(), password, timeouts).await?;
|
||||
|
||||
// XmppStream bound to user session
|
||||
let full_jid = bind(&mut stream, &features, &jid).await?;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use crate::connect::StartTlsServerConnector;
|
|||
use crate::connect::TcpServerConnector;
|
||||
|
||||
mod bind;
|
||||
mod login;
|
||||
pub(crate) mod login;
|
||||
mod stream;
|
||||
|
||||
/// XMPP client connection and state
|
||||
|
|
|
|||
Loading…
Reference in a new issue