client: clear app state after disconnect

This commit is contained in:
Astro 2021-02-21 20:51:56 +01:00
parent c6c7bbc51a
commit 178b6c80ef
2 changed files with 6 additions and 0 deletions

View File

@ -29,6 +29,11 @@ impl App {
tx
}
pub fn clear(&self) {
let mut state = self.state.write().unwrap();
*state = None;
}
// TODO: async drop til 1st header
pub fn subscribe(&self) -> Option<Receiver<Payload>> {
let state = self.state.read().unwrap();

View File

@ -57,6 +57,7 @@ pub async fn run(app: App) {
loop {
run_once(&app).await
.unwrap_or_else(|e| println!("Client: {:?}", e));
app.clear();
sleep(Duration::from_secs(1)).await;
}