tokio-xmpp: use xmpp_parsers::ns everywhere
This commit is contained in:
parent
1a06a09774
commit
e501addb96
9 changed files with 23 additions and 41 deletions
|
|
@ -1,14 +1,12 @@
|
|||
use futures::stream::StreamExt;
|
||||
use std::marker::Unpin;
|
||||
use tokio::io::{AsyncRead, AsyncWrite};
|
||||
use xmpp_parsers::component::Handshake;
|
||||
use xmpp_parsers::{component::Handshake, ns};
|
||||
|
||||
use crate::xmpp_codec::Packet;
|
||||
use crate::xmpp_stream::XMPPStream;
|
||||
use crate::{AuthError, Error};
|
||||
|
||||
const NS_JABBER_COMPONENT_ACCEPT: &str = "jabber:component:accept";
|
||||
|
||||
pub async fn auth<S: AsyncRead + AsyncWrite + Unpin>(
|
||||
stream: &mut XMPPStream<S>,
|
||||
password: String,
|
||||
|
|
@ -19,7 +17,7 @@ pub async fn auth<S: AsyncRead + AsyncWrite + Unpin>(
|
|||
loop {
|
||||
match stream.next().await {
|
||||
Some(Ok(Packet::Stanza(ref stanza)))
|
||||
if stanza.is("handshake", NS_JABBER_COMPONENT_ACCEPT) =>
|
||||
if stanza.is("handshake", ns::COMPONENT_ACCEPT) =>
|
||||
{
|
||||
return Ok(());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use std::pin::Pin;
|
|||
use std::str::FromStr;
|
||||
use std::task::Context;
|
||||
use tokio::net::TcpStream;
|
||||
use xmpp_parsers::{Element, Jid};
|
||||
use xmpp_parsers::{ns, Element, Jid};
|
||||
|
||||
use super::happy_eyeballs::connect;
|
||||
use super::xmpp_codec::Packet;
|
||||
|
|
@ -26,7 +26,6 @@ pub struct Component {
|
|||
}
|
||||
|
||||
type XMPPStream = xmpp_stream::XMPPStream<TcpStream>;
|
||||
const NS_JABBER_COMPONENT_ACCEPT: &str = "jabber:component:accept";
|
||||
|
||||
impl Component {
|
||||
/// Start a new XMPP component
|
||||
|
|
@ -46,7 +45,7 @@ impl Component {
|
|||
let password = password;
|
||||
let tcp_stream = connect(server, None, port).await?;
|
||||
let mut xmpp_stream =
|
||||
xmpp_stream::XMPPStream::start(tcp_stream, jid, NS_JABBER_COMPONENT_ACCEPT.to_owned())
|
||||
xmpp_stream::XMPPStream::start(tcp_stream, jid, ns::COMPONENT_ACCEPT.to_owned())
|
||||
.await?;
|
||||
auth::auth(&mut xmpp_stream, password).await?;
|
||||
Ok(xmpp_stream)
|
||||
|
|
|
|||
Loading…
Reference in a new issue