∅:D[
2.113] → [
3.914:1113]
∅:D[
3.914] → [
3.914:1113]
∅:D[
3.1113] → [
2.114:158]
∅:D[
2.158] → [
3.1158:1257]
∅:D[
3.1158] → [
3.1158:1257]
∅:D[
3.1257] → [
2.159:227]
∅:D[
2.227] → [
3.1313:1591]
∅:D[
3.1313] → [
3.1313:1591]
future::loop_fn(XmppState::new(cmd_recv, signal), |s| {
s.signal.select2(s.cmd_recv.into_future()).then(|r| {
match r {
Ok(Either::A((_x, b))) => {
// got signal, breaks
future::ok(future::Loop::Break(b.into_inner()))
}
Ok(Either::B((x, a))) => {
// got cmd, continue
future::ok(future::Loop::Continue(XmppState::new(x.1, a)))
}
Err(Either::A((e, b))) => {
// got signal error, breaks
error!("Signal error: {}", e);
future::ok(future::Loop::Break(b.into_inner()))
}
Err(Either::B((_e, _a))) => {
// got cmd error, its bad
future::err(tokio::io::Error::new(
tokio::io::ErrorKind::Other,
"Cmd error",
))
let conn = XmppConnection::new(jid, password);
future::loop_fn(XmppState::new(cmd_recv, signal, conn), |s| {
let XmppState {
cmd_recv,
signal,
conn,
} = s;
signal
.select2(conn.connect().and_then(|conn| {
cmd_recv
.into_future()
.map_err(|_| {
error!("Got error on recv cmd");
tokio::io::Error::new(tokio::io::ErrorKind::Other, "Receive cmd error")
}).map(|f| (f, conn))
})).then(|r| {
match r {
Ok(Either::A((_x, b))) => {
// got signal, breaks
Box::new(b.map(|b| future::Loop::Break((Some((b.0).1), b.1))))
as Box<Future<Item = _, Error = _>>
}
Ok(Either::B((x, a))) => {
// got cmd, continue
Box::new(future::ok(future::Loop::Continue(XmppState::new(
(x.0).1,
a,
x.1,
)))) as Box<Future<Item = _, Error = _>>
}
Err(Either::A((e, b))) => {
// got signal error, breaks
error!("Signal error: {}", e);
Box::new(b.map(|b| future::Loop::Break((Some((b.0).1), b.1))))
as Box<Future<Item = _, Error = _>>
}
Err(Either::B((_e, _a))) => {
// got cmd error, its bad
Box::new(future::err(tokio::io::Error::new(
tokio::io::ErrorKind::Other,
"Cmd error",
))) as Box<Future<Item = _, Error = _>>
}