mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-03-27 23:20:54 +03:00
Compare commits
1 Commits
save-confi
...
improve-co
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
253a6d1911 |
@@ -223,6 +223,9 @@ async fn ping_pong(
|
|||||||
) {
|
) {
|
||||||
loop {
|
loop {
|
||||||
let (buf, len) = ProtoEvent::Ping.into();
|
let (buf, len) = ProtoEvent::Ping.into();
|
||||||
|
|
||||||
|
// send 4 pings, at least one must be answered
|
||||||
|
for _ in 0..4 {
|
||||||
if let Err(e) = conn.send(&buf[..len]).await {
|
if let Err(e) = conn.send(&buf[..len]).await {
|
||||||
log::warn!("{addr}: send error `{e}`, closing connection");
|
log::warn!("{addr}: send error `{e}`, closing connection");
|
||||||
let _ = conn.close().await;
|
let _ = conn.close().await;
|
||||||
@@ -231,6 +234,7 @@ async fn ping_pong(
|
|||||||
log::trace!("PING >->->->->- {addr}");
|
log::trace!("PING >->->->->- {addr}");
|
||||||
|
|
||||||
tokio::time::sleep(Duration::from_millis(500)).await;
|
tokio::time::sleep(Duration::from_millis(500)).await;
|
||||||
|
}
|
||||||
|
|
||||||
if !ping_response.borrow_mut().remove(&addr) {
|
if !ping_response.borrow_mut().remove(&addr) {
|
||||||
log::warn!("{addr} did not respond, closing connection");
|
log::warn!("{addr} did not respond, closing connection");
|
||||||
|
|||||||
Reference in New Issue
Block a user