From 547902fe8f0172e9446944cdb4a9e1668d369449 Mon Sep 17 00:00:00 2001 From: Astro Date: Mon, 19 Jun 2017 02:35:21 +0200 Subject: [PATCH] echo_bot: send presence --- examples/echo_bot.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/echo_bot.rs b/examples/echo_bot.rs index df33cf0a..e9761c93 100644 --- a/examples/echo_bot.rs +++ b/examples/echo_bot.rs @@ -2,13 +2,14 @@ extern crate futures; extern crate tokio_core; extern crate tokio_xmpp; extern crate jid; +extern crate xml; use std::str::FromStr; use tokio_core::reactor::Core; -use futures::{Future, Stream}; +use futures::{Future, Stream, Sink}; +use jid::Jid; use tokio_xmpp::TcpClient; use tokio_xmpp::xmpp_codec::Packet; -use jid::Jid; fn main() { let jid = Jid::from_str("astrobot@example.net").expect("JID"); @@ -38,6 +39,11 @@ fn main() { stream.bind() }).and_then(|stream| { println!("Bound to {}", stream.jid); + + let presence = xml::Element::new("presence".to_owned(), None, vec![]); + stream.send(Packet::Stanza(presence)) + .map_err(|e| format!("{}", e)) + }).and_then(|stream| { stream.for_each(|event| { match event { Packet::Stanza(el) => println!("<< {}", el),