fix a rare connection glitch

This commit is contained in:
Daniella / Tove 2022-08-23 10:06:09 +02:00
parent bd3e770a0d
commit 2a675aa9d5
2 changed files with 17 additions and 17 deletions

View file

@ -204,11 +204,11 @@ pub fn gui() -> Result<(), iui::UIError> {
let uib = uib1.clone();
let barb = barb1.clone();
uib1.get().queue_main(move || {
let percentage = (f * 100 as f32) as u32;
let percentage = (f * 100 as f32) as i32;
if percentage != *lpb1.get() {
barb.get().set_value(
uib.get(),
ProgressBarValue::Determinate(percentage),
ProgressBarValue::Determinate(percentage as u32),
);
*lpb1.get() = percentage;
}
@ -240,11 +240,11 @@ pub fn gui() -> Result<(), iui::UIError> {
let uib = uib1.clone();
let barb = barb1.clone();
uib1.get().queue_main(move || {
let percentage = (f * 100 as f32) as u32;
let percentage = (f * 100 as f32) as i32;
if percentage != *lpb1.get() {
barb.get().set_value(
uib.get(),
ProgressBarValue::Determinate(percentage),
ProgressBarValue::Determinate(percentage as u32),
);
*lpb1.get() = percentage;
}

View file

@ -226,10 +226,7 @@ impl SafeReadWrite {
}
if unix_millis() - start > 10000 {
println!("\r\x1b[K10s passed since last packet ==> Contact broke. Trying to resend packet...");
let buf = self
.last_transmitted
.get(&idn)
.expect("Unable to recover from connection loss.");
if let Some(buf) = self.last_transmitted.get(&idn) {
loop {
match self.socket.send(buf) {
Ok(x) => {
@ -244,6 +241,9 @@ impl SafeReadWrite {
break;
}
start = unix_millis();
} else {
break; // Latest packet was already ACK'd ==> No packets properly lost ==> Can continue with next packet.
}
}
if !wait {
break;