Reconnect Client after disconnect in iced_sentinel
This commit is contained in:
parent
88a688e6ab
commit
df62075040
2 changed files with 8 additions and 6 deletions
|
|
@ -46,18 +46,20 @@ async fn run(mut receiver: mpsc::Receiver<Input>) {
|
||||||
&mut stream,
|
&mut stream,
|
||||||
Input::Connected {
|
Input::Connected {
|
||||||
at: SystemTime::now(),
|
at: SystemTime::now(),
|
||||||
version,
|
version: version.clone(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
while let Some(input) = receiver.recv().await {
|
while let Some(input) = receiver.recv().await {
|
||||||
if send(&mut stream, input).await.is_err() {
|
match send(&mut stream, input).await {
|
||||||
break;
|
Ok(()) => {}
|
||||||
|
Err(error) => {
|
||||||
|
log::warn!("Error sending message to sentinel server: {error}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
time::sleep(time::Duration::from_secs(2)).await;
|
time::sleep(time::Duration::from_secs(2)).await;
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ pub fn run() -> impl Stream<Item = Event> {
|
||||||
},
|
},
|
||||||
State::Connected(stream) => match receive(stream).await {
|
State::Connected(stream) => match receive(stream).await {
|
||||||
Ok((stream, input)) => {
|
Ok((stream, input)) => {
|
||||||
let event = match dbg!(input) {
|
let event = match input {
|
||||||
Input::Connected { at, version } => {
|
Input::Connected { at, version } => {
|
||||||
Event::Connected { at, version }
|
Event::Connected { at, version }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue