Show upgrade required message when reconnecting after a protocol change

Co-authored-by: Antonio Scandurra <me@as-cii.com>
This commit is contained in:
Max Brunsfeld 2022-06-21 10:26:34 -07:00
parent 69bd6bf1f3
commit 6a2c5e0dc1
3 changed files with 23 additions and 36 deletions

View file

@ -318,16 +318,20 @@ impl Client {
let mut delay = Duration::from_millis(100);
while let Err(error) = this.authenticate_and_connect(true, &cx).await {
log::error!("failed to connect {}", error);
this.set_status(
Status::ReconnectionError {
next_reconnection: Instant::now() + delay,
},
&cx,
);
cx.background().timer(delay).await;
delay = delay
.mul_f32(rng.gen_range(1.0..=2.0))
.min(reconnect_interval);
if matches!(*this.status().borrow(), Status::ConnectionError) {
this.set_status(
Status::ReconnectionError {
next_reconnection: Instant::now() + delay,
},
&cx,
);
cx.background().timer(delay).await;
delay = delay
.mul_f32(rng.gen_range(1.0..=2.0))
.min(reconnect_interval);
} else {
break;
}
}
}));
}