impl stream for client
This commit is contained in:
parent
547902fe8f
commit
1e2672ba50
7 changed files with 254 additions and 70 deletions
|
|
@ -4,14 +4,10 @@ use futures::*;
|
|||
use tokio_io::{AsyncRead, AsyncWrite};
|
||||
use tokio_io::codec::Framed;
|
||||
use xml;
|
||||
use sasl::common::{Credentials, ChannelBinding};
|
||||
use jid::Jid;
|
||||
|
||||
use xmpp_codec::*;
|
||||
use stream_start::*;
|
||||
use starttls::{NS_XMPP_TLS, StartTlsClient};
|
||||
use client_auth::ClientAuth;
|
||||
use client_bind::ClientBind;
|
||||
|
||||
pub const NS_XMPP_STREAM: &str = "http://etherx.jabber.org/streams";
|
||||
|
||||
|
|
@ -42,28 +38,6 @@ impl<S: AsyncRead + AsyncWrite> XMPPStream<S> {
|
|||
pub fn restart(self) -> StreamStart<S> {
|
||||
Self::from_stream(self.stream.into_inner(), self.jid)
|
||||
}
|
||||
|
||||
pub fn can_starttls(&self) -> bool {
|
||||
self.stream_features
|
||||
.get_child("starttls", Some(NS_XMPP_TLS))
|
||||
.is_some()
|
||||
}
|
||||
|
||||
pub fn starttls(self) -> StartTlsClient<S> {
|
||||
StartTlsClient::from_stream(self)
|
||||
}
|
||||
|
||||
pub fn auth(self, username: String, password: String) -> Result<ClientAuth<S>, String> {
|
||||
let creds = Credentials::default()
|
||||
.with_username(username)
|
||||
.with_password(password)
|
||||
.with_channel_binding(ChannelBinding::None);
|
||||
ClientAuth::new(self, creds)
|
||||
}
|
||||
|
||||
pub fn bind(self) -> ClientBind<S> {
|
||||
ClientBind::new(self)
|
||||
}
|
||||
}
|
||||
|
||||
/// Proxy to self.stream
|
||||
|
|
|
|||
Loading…
Reference in a new issue