Connect to xmpp server
[?]
Oct 28, 2018, 5:27 PM
E4YEIQYO6OX5U225LMB4YWIT5LK2VDBH5HVLV5C5HCIWQWVNVFOACDependencies
- [2]
Z7OFWSBLRefactor account data - [3]
PHPCAQ6ZUse env logger. Implement command loop - [4]
AXDOLAOAIntroduce xmpp client - [5]
AVBHYHOAStop xmpp thread by shudown - [6]
F5UQL2FBManage xmpp connection in cmd processing loop - [*]
FVVPKFTLInitial commit - [*]
HKSQO7JZEnable hyper http server and configuration - [*]
YGC7ZD7NUse logger
Change contents
- edit in src/xmpp.rs at line 1
use tokio::prelude::stream; - replacement in src/xmpp.rs at line 5
use tokio_xmpp::Client;use tokio_xmpp::{Client, Event}; - replacement in src/xmpp.rs at line 11
inner: Option<Client>,inner: Option<(stream::SplitSink<Client>, stream::SplitStream<Client>)>, - replacement in src/xmpp.rs at line 24[3.380]→[3.380:445](∅→∅),[3.445]→[2.125:179](∅→∅),[2.179]→[3.159:205](∅→∅),[3.159]→[3.159:205](∅→∅),[3.205]→[2.180:259](∅→∅),[2.259]→[3.268:370](∅→∅),[3.268]→[3.268:370](∅→∅),[3.370]→[2.260:335](∅→∅)
fn connect<E>(self) -> impl Future<Item = Self, Error = E> {let XmppConnection { account, inner } = self;let inner = inner.unwrap_or_else(|| {let mut res_client = Client::new(&account.jid, &account.password);while let Err(e) = res_client {error!("Cann't init xmpp client: {}", e);res_client = Client::new(&account.jid, &account.password);fn connect<E: 'static>(self) -> impl Future<Item = Self, Error = E> {info!("xmpp connection...");future::loop_fn(self, |XmppConnection { account, inner }| {if let Some(inner) = inner {Box::new(future::ok(future::Loop::Break(XmppConnection {account,inner: Some(inner),}))) as Box<Future<Item = _, Error = E>>} else {info!("xmpp initialization...");let mut res_client = Client::new(&account.jid, &account.password);while let Err(e) = res_client {error!("Cann't init xmpp client: {}", e);res_client = Client::new(&account.jid, &account.password);}let client = res_client.expect("Cann't init xmpp client");info!("xmpp initialized");// future to wait for onlinelet (sink, stream) = client.split();Box::new(future::loop_fn((sink, stream, account),|(sink, stream, account)| {stream.into_future().then(|r| match r {Ok((event, stream)) => match event {Some(Event::Online) => {info!("Online");future::ok(future::Loop::Break(future::Loop::Break(XmppConnection {account,inner: Some((sink, stream)),},)))}Some(Event::Stanza(s)) => {info!("xmpp stanza: {:?}", s);future::ok(future::Loop::Continue((sink, stream, account)))}_ => {warn!("Disconnected");future::ok(future::Loop::Break(future::Loop::Continue(XmppConnection {account,inner: None,},)))}},Err((e, _)) => {error!("xmpp receive error: {}", e);future::ok(future::Loop::Break(future::Loop::Continue(XmppConnection {account,inner: None,},)))}})},)) - edit in src/xmpp.rs at line 86[3.443]→[3.443:584](∅→∅),[3.443]→[3.443:584](∅→∅),[3.584]→[3.499:536](∅→∅),[3.499]→[3.499:536](∅→∅),[3.536]→[2.336:357](∅→∅),[2.357]→[3.600:632](∅→∅),[3.624]→[3.600:632](∅→∅),[3.600]→[3.600:632](∅→∅)
let client = res_client.expect("Cann't init xmpp client");info!("xmpp initialized");client});future::ok(XmppConnection {account,inner: Some(inner), - replacement in src/xmpp.rs at line 108
pub fn xmpp_process<F: 'static>(pub fn xmpp_process<F>( - replacement in src/xmpp.rs at line 114
F: future::Future<Item = ()>,F: future::Future<Item = ()> + 'static, - edit in src/xmpp.rs at line 129
info!("xmpp connected!"); - edit in src/xmpp.rs at line 139
info!("Got signal"); - edit in src/xmpp.rs at line 145
info!("Got cmd"); - replacement in src/xmpp.rs at line 159
Err(Either::B((_e, _a))) => {Err(Either::B((e, _a))) => { - edit in src/xmpp.rs at line 161
error!("Cmd error: {}", e); - edit in src/main.rs at line 7[9.61][10.0]
extern crate minidom; - edit in Cargo.toml at line 19[10.269][9.2214]
minidom = "0.10" - edit in Cargo.lock at line 631
][[package]]name = "minidom"version = "0.10.0"source = "registry+https://github.com/rust-lang/crates.io-index"dependencies = ["failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)","failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)","quick-xml 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", - edit in Cargo.lock at line 866
source = "registry+https://github.com/rust-lang/crates.io-index"dependencies = ["encoding_rs 0.8.10 (registry+https://github.com/rust-lang/crates.io-index)","failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)","log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)","memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",][[package]]name = "quick-xml"version = "0.13.1" - edit in Cargo.lock at line 1070[10.2078][9.35429]
"minidom 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - edit in Cargo.lock at line 1875
"checksum minidom 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "275024eea6c6ff4ace22f2750843831183785288eec1cff91a4e6b8898cf94f9" - edit in Cargo.lock at line 1903
"checksum quick-xml 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1b62a38216952bff95085ad664b772492288a96a25544f48d25e7200de1d7db7"