mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
ClientBind: replace with xmpp_parsers::bind::Bind
This commit is contained in:
parent
89a1d3e1cf
commit
06b97ea228
1 changed files with 5 additions and 16 deletions
|
@ -5,6 +5,7 @@ use futures::{Future, Poll, Async, sink, Sink, Stream};
|
||||||
use tokio_io::{AsyncRead, AsyncWrite};
|
use tokio_io::{AsyncRead, AsyncWrite};
|
||||||
use jid::Jid;
|
use jid::Jid;
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
|
use xmpp_parsers::bind::Bind;
|
||||||
|
|
||||||
use xmpp_codec::Packet;
|
use xmpp_codec::Packet;
|
||||||
use xmpp_stream::XMPPStream;
|
use xmpp_stream::XMPPStream;
|
||||||
|
@ -30,7 +31,10 @@ impl<S: AsyncWrite> ClientBind<S> {
|
||||||
// return the (probably // usable) stream immediately
|
// return the (probably // usable) stream immediately
|
||||||
ClientBind::Unsupported(stream),
|
ClientBind::Unsupported(stream),
|
||||||
Some(_) => {
|
Some(_) => {
|
||||||
let iq = make_bind_request(stream.jid.resource.as_ref());
|
let resource = stream.jid.resource.clone();
|
||||||
|
let iq = Element::from(
|
||||||
|
Bind::new(resource)
|
||||||
|
);
|
||||||
let send = stream.send(Packet::Stanza(iq));
|
let send = stream.send(Packet::Stanza(iq));
|
||||||
ClientBind::WaitSend(send)
|
ClientBind::WaitSend(send)
|
||||||
},
|
},
|
||||||
|
@ -38,21 +42,6 @@ impl<S: AsyncWrite> ClientBind<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_bind_request(resource: Option<&String>) -> Element {
|
|
||||||
let iq = Element::builder("iq")
|
|
||||||
.attr("type", "set")
|
|
||||||
.attr("id", BIND_REQ_ID);
|
|
||||||
let mut bind_el = Element::builder("bind")
|
|
||||||
.ns(NS_XMPP_BIND);
|
|
||||||
if let Some(resource) = resource {
|
|
||||||
let resource_el = Element::builder("resource")
|
|
||||||
.append(resource);
|
|
||||||
bind_el = bind_el.append(resource_el.build());
|
|
||||||
}
|
|
||||||
iq.append(bind_el.build())
|
|
||||||
.build()
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: AsyncRead + AsyncWrite> Future for ClientBind<S> {
|
impl<S: AsyncRead + AsyncWrite> Future for ClientBind<S> {
|
||||||
type Item = XMPPStream<S>;
|
type Item = XMPPStream<S>;
|
||||||
type Error = String;
|
type Error = String;
|
||||||
|
|
Loading…
Reference in a new issue