Don't split xmpp receiving and sending

[?]
Dec 16, 2018, 8:14 PM
O2GM5J4FSOXLTJURP2K6JMCBRAJ2JPJ723A43CR6AT2VQQQYRHFQC

Dependencies

  • [2] X6L47BHQ Use different structure for established xmpp connection
  • [3] FV6BJ5K6 Send self-presence and store account info in Rc so it willbe used in some future in parallel
  • [4] VS6AHRWI Move XMPP to separate dir
  • [5] PBRUH4BJ Rename optional XmppConnection to MaybeXmppConnection

Change contents

  • replacement in src/xmpp/mod.rs at line 12
    [3.478][3.269:346](),[3.269][3.269:346]()
    inner: Option<(stream::SplitSink<Client>, stream::SplitStream<Client>)>,
    [3.478]
    [2.0]
    inner: Option<Client>,
  • replacement in src/xmpp/mod.rs at line 17
    [2.74][2.74:143]()
    inner: (stream::SplitSink<Client>, stream::SplitStream<Client>),
    [2.74]
    [2.143]
    inner: Client,
  • replacement in src/xmpp/mod.rs at line 58
    [3.1522][3.1522:1576](),[3.1522][3.1522:1576]()
    Self::online(client.split(), account)
    [3.1522]
    [2.582]
    Self::online(client, account)
  • replacement in src/xmpp/mod.rs at line 71
    [3.2003][3.2003:2085](),[3.2003][3.2003:2085]()
    (sink, stream): (stream::SplitSink<Client>, stream::SplitStream<Client>),
    [3.2003]
    [3.528]
    client: Client,
  • replacement in src/xmpp/mod.rs at line 74
    [3.649][3.2180:2498](),[2.728][3.2180:2498](),[3.2180][3.2180:2498](),[3.2498][2.729:805](),[2.805][3.2574:2615](),[3.350][3.2574:2615](),[3.2574][3.2574:2615](),[3.2615][2.806:861](),[2.861][3.2676:3237](),[3.2676][3.2676:3237]()
    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(XmppConnection {
    account,
    inner: (sink, stream),
    }))
    }
    Some(Event::Stanza(s)) => {
    info!("xmpp stanza: {:?}", s);
    future::ok(future::Loop::Continue((sink, stream, account)))
    }
    _ => {
    warn!("Disconnected");
    future::err(account)
    }
    },
    Err((e, _)) => {
    error!("xmpp receive error: {}", e);
    [2.728]
    [3.3237]
    Box::new(future::loop_fn((client, 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");
  • replacement in src/xmpp/mod.rs at line 92
    [3.3304][3.3304:3349](),[3.3304][3.3304:3349]()
    })
    },
    ))
    [3.3304]
    [3.3349]
    },
    Err((e, _)) => {
    error!("xmpp receive error: {}", e);
    future::err(account)
    }
    })
    }))
  • replacement in src/xmpp/mod.rs at line 105
    [2.942][2.942:978]()
    let (sink, stream) = inner;
    [2.942]
    [2.978]
    let client = inner;
  • edit in src/xmpp/mod.rs at line 110
    [2.1108]
    [2.1108]
    let account2 = account.clone();
  • replacement in src/xmpp/mod.rs at line 112
    [2.1126][2.1126:1158]()
    sink.send(presence)
    [2.1126]
    [2.1158]
    client
    .send(presence)
  • replacement in src/xmpp/mod.rs at line 118
    [2.1333][2.1333:1472]()
    .join(
    future::loop_fn((account.clone(), stream), |(account, stream)| {
    stream
    [2.1333]
    [2.1472]
    .and_then(move |client| {
    future::loop_fn((account2.clone(), client), |(account, client)| {
    client
  • replacement in src/xmpp/mod.rs at line 126
    [2.1746][2.1746:1816]()
    .and_then(|(event, stream)| match event {
    [2.1746]
    [2.1816]
    .and_then(|(event, client)| match event {
  • replacement in src/xmpp/mod.rs at line 135
    [2.2387][2.2387:2471]()
    future::ok(future::Loop::Break(stream))
    [2.2387]
    [3.2608]
    future::ok(future::Loop::Break(client))
  • replacement in src/xmpp/mod.rs at line 137
    [3.2657][2.2472:2570]()
    future::ok(future::Loop::Continue((account, stream)))
    [3.2657]
    [3.2743]
    future::ok(future::Loop::Continue((account, client)))
  • replacement in src/xmpp/mod.rs at line 146
    [2.2872][2.2872:2965]()
    .map_err(|e| format!("waiting self-presence: {}", e)),
    )
    [2.2872]
    [2.2965]
    .map_err(|e| format!("waiting self-presence: {}", e))
    })