refactor into stream_start + xmpp_stream
This commit is contained in:
parent
98e7a2fbf4
commit
c32a38874c
7 changed files with 239 additions and 117 deletions
|
|
@ -8,7 +8,8 @@ use std::io::BufReader;
|
|||
use std::fs::File;
|
||||
use tokio_core::reactor::Core;
|
||||
use futures::{Future, Stream};
|
||||
use tokio_xmpp::{Packet, TcpClient, StartTlsClient};
|
||||
use tokio_xmpp::TcpClient;
|
||||
use tokio_xmpp::xmpp_codec::Packet;
|
||||
use rustls::ClientConfig;
|
||||
|
||||
fn main() {
|
||||
|
|
@ -26,8 +27,13 @@ fn main() {
|
|||
let client = TcpClient::connect(
|
||||
&addr,
|
||||
&core.handle()
|
||||
).and_then(|stream| StartTlsClient::from_stream(stream, arc_config)
|
||||
).and_then(|stream| {
|
||||
if stream.can_starttls() {
|
||||
stream.starttls(arc_config)
|
||||
} else {
|
||||
panic!("No STARTTLS")
|
||||
}
|
||||
}).and_then(|stream| {
|
||||
stream.for_each(|event| {
|
||||
match event {
|
||||
Packet::Stanza(el) => println!("<< {}", el),
|
||||
|
|
|
|||
Loading…
Reference in a new issue