Compare commits

...

1 Commits

Author SHA1 Message Date
Conrad Irwin
769c23f944 Better client-side logging of connection errors 2024-05-23 14:15:12 -06:00

View File

@@ -972,6 +972,27 @@ impl Client {
});
let handle_io = executor.spawn(handle_io);
let original_connection_id = connection_id;
cx.spawn({
let this = self.clone();
move |cx| async move {
match handle_io.await {
Ok(()) => {
if let Status::Connected { connection_id, .. } = &*this.status().borrow() {
if *connection_id == original_connection_id {
this.set_status(Status::SignedOut, &cx);
}
}
}
Err(err) => {
log::error!("connection error: {:?}", err);
this.set_status(Status::ConnectionLost, &cx);
}
}
}
})
.detach();
let peer_id = async {
log::info!("waiting for server hello");
let message = incoming
@@ -1031,29 +1052,6 @@ impl Client {
})
.detach();
cx.spawn({
let this = self.clone();
move |cx| async move {
match handle_io.await {
Ok(()) => {
if *this.status().borrow()
== (Status::Connected {
connection_id,
peer_id,
})
{
this.set_status(Status::SignedOut, &cx);
}
}
Err(err) => {
log::error!("connection error: {:?}", err);
this.set_status(Status::ConnectionLost, &cx);
}
}
}
})
.detach();
Ok(())
}