Skip to content

Commit

Permalink
Driver: Fix incorrect leave behaviour in Drop handler
Browse files Browse the repository at this point in the history
Sending poison messages should suffice to kill the voice session: attempting to `.leave()`. Fixes #88.

This was tested using `cargo make ready` and the modified `serenity/voice/` example.
  • Loading branch information
FelixMcFelix committed Aug 17, 2021
1 parent 3efe756 commit dad48ca
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/serenity/voice/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ features = ["client", "standard_framework", "voice", "rustls_backend"]

[dependencies.tokio]
version = "1.0"
features = ["macros", "rt-multi-thread"]
features = ["macros", "rt-multi-thread", "signal"]
7 changes: 6 additions & 1 deletion examples/serenity/voice/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ async fn main() {
.await
.expect("Err creating client");

let _ = client.start().await.map_err(|why| println!("Client ended: {:?}", why));
tokio::spawn(async move {
let _ = client.start().await.map_err(|why| println!("Client ended: {:?}", why));
});

tokio::signal::ctrl_c().await;
println!("Received Ctrl-C, shutting down.");
}

#[command]
Expand Down
1 change: 0 additions & 1 deletion src/driver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ impl Drop for Driver {
/// Leaves the current connected voice channel, if connected to one, and
/// forgets all configurations relevant to this Handler.
fn drop(&mut self) {
self.leave();
let _ = self.sender.send(CoreMessage::Poison);
}
}
Expand Down

0 comments on commit dad48ca

Please sign in to comment.