Use new processing code to wait online
[?]
Dec 29, 2018, 8:56 PM
H7R7Y3FQHYR44R65YLHUAL6SSSFEMLDJTKBXMG6M7N6GDMHEDYNQCDependencies
- [2]
XGP44R5HRework stopping xmpp connection - [3]
OGMBXBKPMove online to XmppConnection - [4]
X6L47BHQUse different structure for established xmpp connection - [5]
2L3JHRULCreate separate functions to process incoming XMPP stanzas - [6]
FDHRCKH5Unneded Box - [7]
AGIW6YR3Use shared future for signal everywhere - [8]
O2GM5J4FDon't split xmpp receiving and sending - [9]
VS6AHRWIMove XMPP to separate dir - [10]
NDDQQP2PUpdate deps
Change contents
- replacement in src/xmpp/mod.rs at line 44
F: future::Future + 'static,F: future::Future + Clone + 'static, - edit in src/xmpp/mod.rs at line 56
.clone() - replacement in src/xmpp/mod.rs at line 58
future::loop_fn(account, |account| {future::loop_fn(account, move |account| { - replacement in src/xmpp/mod.rs at line 73
.online().processing(XmppConnection::online, stop_future.clone()).map(|(xmpp, _)| xmpp).map_err(|(acc, _)| acc) - replacement in src/xmpp/mod.rs at line 114
Item = (Self, Result<Either<F, T>, E>),Error = (std::rc::Rc<config::Account>, Result<Either<F, T>, E>),Item = (Self, Result<Either<F, T>, failure::Error>),Error = (std::rc::Rc<config::Account>,Result<Either<F, T>, failure::Error>,), - replacement in src/xmpp/mod.rs at line 122
S: FnMut(&mut Self, &Event) -> bool,E: Into<failure::Error>,S: FnMut(&mut Self, &Event) -> Result<bool, failure::Error>, - replacement in src/xmpp/mod.rs at line 137
if stop_condition(&mut xmpp, &event) {future::ok(future::Loop::Break((xmpp, Ok(Either::A(b)))))} else {future::ok(future::Loop::Continue((xmpp, b, stop_condition)))match stop_condition(&mut xmpp, &event) {Ok(true) => {future::ok(future::Loop::Break((xmpp, Ok(Either::A(b)))))}Ok(false) => {future::ok(future::Loop::Continue((xmpp, b, stop_condition)))}Err(e) => future::err((xmpp.account, Err(e))), - replacement in src/xmpp/mod.rs at line 165
Err(e),Err(e.into()), - replacement in src/xmpp/mod.rs at line 168
future::err((account, Err(e)))future::err((account, Err(e.into()))) - replacement in src/xmpp/mod.rs at line 178[3.2767]→[2.5606:5704](∅→∅),[2.5704]→[3.2865:2899](∅→∅),[3.860]→[3.2865:2899](∅→∅),[3.2865]→[3.2865:2899](∅→∅),[3.2899]→[2.5705:5892](∅→∅),[2.5892]→[3.3086:3180](∅→∅),[3.1051]→[3.3086:3180](∅→∅),[3.3086]→[3.3086:3180](∅→∅),[3.3180]→[2.5893:5969](∅→∅),[2.5969]→[3.3256:3297](∅→∅),[3.1133]→[3.3256:3297](∅→∅),[3.3256]→[3.3256:3297](∅→∅),[3.3297]→[2.5970:6017](∅→∅),[2.6017]→[3.3344:3513](∅→∅),[3.1195]→[3.3344:3513](∅→∅),[3.3344]→[3.3344:3513](∅→∅),[3.3513]→[2.6018:6100](∅→∅),[2.6100]→[3.3595:3899](∅→∅),[3.1284]→[3.3595:3899](∅→∅),[3.3595]→[3.3595:3899](∅→∅),[3.3899]→[3.3237:3304](∅→∅),[3.832]→[3.3237:3304](∅→∅),[3.1796]→[3.3237:3304](∅→∅),[3.864]→[3.3237:3304](∅→∅),[3.3237]→[3.3237:3304](∅→∅),[3.3304]→[3.3900:3945](∅→∅)
fn online(self) -> impl Future<Item = XmppConnection, Error = std::rc::Rc<config::Account>> {Box::new(future::loop_fn((self.inner, self.account),|(client, account)| {client.into_future().then(|r| match r {Ok((event, client)) => match event {Some(Event::Online) => {info!("Online");future::ok(future::Loop::Break(XmppConnection {account,inner: client,}))}Some(Event::Stanza(s)) => {info!("xmpp stanza: {:?}", s);future::ok(future::Loop::Continue((client, account)))}_ => {warn!("Disconnected");future::err(account)}},Err((e, _)) => {error!("xmpp receive error: {}", e);future::err(account)}})},))fn online(&mut self, event: &Event) -> Result<bool, failure::Error> {match event {Event::Online => {info!("Online!");Ok(true)}Event::Stanza(s) => {warn!("Stanza before online: {:?}", s);Ok(false)}_ => {error!("Disconnected while online");Err(format_err!("Disconnected while online"))}}