mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 05:15:00 +00:00
Attempt to reconnect when a reconnection is lost
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
6723db30be
commit
2179a70436
1 changed files with 16 additions and 1 deletions
|
@ -229,7 +229,21 @@ impl Client {
|
|||
loop {
|
||||
match this.establish_connection(&connection_opts, &cx).await {
|
||||
Ok(conn) => {
|
||||
// TODO: use Peer::reconnect.
|
||||
if let Ok(io_work) =
|
||||
this.peer.resume_connection(connection_id, conn).await
|
||||
{
|
||||
this.maintain_connection_status(
|
||||
connection_id,
|
||||
connection_opts,
|
||||
cx.background().spawn(io_work),
|
||||
&cx,
|
||||
);
|
||||
} else {
|
||||
this.set_status(
|
||||
Status::ConnectionLost { user_id },
|
||||
&cx,
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
Err(ConnectError::ReconnectRejected) => {
|
||||
|
@ -259,6 +273,7 @@ impl Client {
|
|||
async move {
|
||||
if let Err(_) = timer.race(reconnect).await {
|
||||
this.set_status(Status::ConnectionLost { user_id }, &cx);
|
||||
this.peer.remove_connection(connection_id).await;
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
|
Loading…
Reference in a new issue