diff --git a/prototypes/ptth_quic_client_gui/src/main.rs b/prototypes/ptth_quic_client_gui/src/main.rs index 438184d..cc9ad6f 100644 --- a/prototypes/ptth_quic_client_gui/src/main.rs +++ b/prototypes/ptth_quic_client_gui/src/main.rs @@ -59,8 +59,7 @@ impl GuiClient <'_> { )); self.gui_ports [port_idx].set_forwarding (true); - - self.frame_status.set_label ("Forwarding 1 port"); + self.sync_status (); Ok (()) } @@ -71,10 +70,22 @@ impl GuiClient <'_> { } self.gui_ports [port_idx].set_forwarding (false); - self.frame_status.set_label ("Forwarding 0 ports"); + self.sync_status (); Ok (()) } + + fn open_ports (&self) -> usize { + self.forwarding_instances.iter () + .map (|x| if x.is_some () { 1 } else { 0 }) + .sum () + } + + fn sync_status (&mut self) { + let open_ports = self.open_ports (); + + self.frame_status.set_label (&format! ("Forwarding {} ports", open_ports)); + } } fn main () -> anyhow::Result <()> {