added restart limits and feedback
This commit is contained in:
parent
a37f5ed266
commit
8924d2ab8f
4 changed files with 38 additions and 9 deletions
|
@ -20,6 +20,18 @@ impl TrackerMetrics {
|
|||
ret
|
||||
}
|
||||
|
||||
pub fn starting_connection(&mut self, fail_count: Option<usize>) {
|
||||
self.clear_times();
|
||||
|
||||
if let Ok(mut writer) = self.header_text.write() {
|
||||
writer.clear();
|
||||
match fail_count {
|
||||
None => writer.push_str("Status: Connecting ..."),
|
||||
Some(v) => writer.push_str(&format!("Status: Attempt {}/5", v)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clear_times(&mut self) {
|
||||
for _ in 0..10 {
|
||||
self.tracker_times.pop_front();
|
||||
|
|
|
@ -43,10 +43,27 @@ pub async fn remote_video_loop(
|
|||
.build()
|
||||
.expect("Could not build video info!");
|
||||
|
||||
let mut fail_count = 0;
|
||||
{
|
||||
let mut tm = tracker_metrics.lock().await;
|
||||
tm.starting_connection(None);
|
||||
}
|
||||
|
||||
loop {
|
||||
socket_state.is_connected.store(true, Ordering::SeqCst);
|
||||
|
||||
match connect_async(&conn_string).await {
|
||||
Err(e) => {
|
||||
fail_count += 1;
|
||||
{
|
||||
let mut tm = tracker_metrics.lock().await;
|
||||
tm.starting_connection(Some(fail_count));
|
||||
}
|
||||
|
||||
if fail_count >= 5 {
|
||||
break;
|
||||
}
|
||||
|
||||
error!("Could not connect to remote video loop! Trying again in 1 seconds: {e}");
|
||||
sleep_until(Instant::now() + Duration::from_secs(1)).await;
|
||||
}
|
||||
|
@ -120,16 +137,15 @@ pub async fn remote_video_loop(
|
|||
}
|
||||
}
|
||||
if !socket_state.stay_connected.load(Ordering::SeqCst) {
|
||||
info!("Shutting down remote video loop");
|
||||
|
||||
{
|
||||
let mut tm = tracker_metrics.lock().await;
|
||||
tm.clear_times();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
info!("Shutting down remote video loop");
|
||||
|
||||
{
|
||||
let mut tm = tracker_metrics.lock().await;
|
||||
tm.clear_times();
|
||||
}
|
||||
socket_state.is_connected.store(false, Ordering::SeqCst);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,13 +29,14 @@ impl LiveViewPanel {
|
|||
// let conn_status_label = Label::new(Some(&"No Connection".to_string()));
|
||||
let cam_status_label = Label::builder()
|
||||
.label("No Connection".to_string())
|
||||
.css_classes(vec!["NoConnection"])
|
||||
.can_focus(true)
|
||||
.build();
|
||||
|
||||
let adjustment_label = Label::builder()
|
||||
.label("X: 0 Y: )")
|
||||
.justify(gtk::Justification::Center)
|
||||
.css_classes(vec!["JoystickCurrent", "NoConnection"])
|
||||
.css_classes(vec!["JoystickCurrent"])
|
||||
.build();
|
||||
|
||||
let webcam_picture = gtk::Picture::builder().can_focus(false).build();
|
||||
|
|
|
@ -235,7 +235,7 @@ pub fn build_ui(app: &Application, config: Arc<RwLock<AppConfig>>, runtime: Hand
|
|||
|
||||
tracker_enable_toggle.set_label("Press to Connect Tracker");
|
||||
tracker_enable_toggle.set_active(false);
|
||||
} else if reader.contains("Degraded") {
|
||||
} else if reader.contains("Degraded") || reader.contains("Connecting") {
|
||||
tracker_status_label.set_css_classes(&["LoadingConnection"]);
|
||||
|
||||
tracker_enable_toggle.set_label("Press to Connect");
|
||||
|
|
Loading…
Reference in a new issue