handle timeouts based on the existence of last_handshake
This commit is contained in:
parent
2acbb6d574
commit
a2cda16977
@ -30,23 +30,9 @@ pub(crate) fn gen_events(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let timedout_now = || {
|
let timedout_now = || !cur.last_handshake.is_some();
|
||||||
if let Some(shake) = cur.last_handshake {
|
|
||||||
if let Ok(el) = shake.elapsed() {
|
|
||||||
return el > timeout && el + poll_interval < timeout;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
true
|
|
||||||
};
|
|
||||||
|
|
||||||
let timedout_prev = || {
|
let timedout_prev = || !prev.last_handshake.is_some();
|
||||||
if let Some(shake) = prev.last_handshake {
|
|
||||||
if let Ok(el) = shake.elapsed().map(|el| el - poll_interval) {
|
|
||||||
return el > timeout && el < timeout + poll_interval;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
true
|
|
||||||
};
|
|
||||||
|
|
||||||
match (timedout_prev(), timedout_now()) {
|
match (timedout_prev(), timedout_now()) {
|
||||||
(false, true) => listeners.disconnected(&cur),
|
(false, true) => listeners.disconnected(&cur),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user