implement logout command

fixes #470
This commit is contained in:
Henrik Friedrichsen
2021-03-22 21:56:22 +01:00
parent 5f87e3cd79
commit a0231362f1
3 changed files with 22 additions and 0 deletions

View File

@@ -71,6 +71,7 @@ enum WorkerCommand {
Seek(u32),
SetVolume(u16),
RequestToken(oneshot::Sender<Token>),
Shutdown,
}
#[derive(Clone, Debug, PartialEq)]
@@ -191,6 +192,10 @@ impl futures::Future for Worker {
self.token_task = Spotify::get_token(&self.session, sender);
progress = true;
}
WorkerCommand::Shutdown => {
self.player.stop();
self.session.shutdown();
}
}
}
@@ -943,6 +948,10 @@ impl Spotify {
self.cfg.with_state_mut(|mut s| s.volume = volume);
self.send_worker(WorkerCommand::SetVolume(Self::log_scale(volume)));
}
pub fn shutdown(&self) {
self.send_worker(WorkerCommand::Shutdown);
}
}
#[derive(Debug, PartialEq)]