aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/src/local_player.rs
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2023-02-12 22:56:20 -0600
committermat <github@matdoes.dev>2023-02-12 22:56:20 -0600
commit1b3d6f9581689e9caa0e2dd14dcf48c20fb06ed7 (patch)
tree0fbc933e220ffd9d3a848c12c38d1889fcec39a6 /azalea-client/src/local_player.rs
parent913f17299b85fb58c5c463a3dc4db8eb7e2d9f76 (diff)
downloadazalea-drasl-1b3d6f9581689e9caa0e2dd14dcf48c20fb06ed7.tar.xz
DisconnectEvent
Diffstat (limited to 'azalea-client/src/local_player.rs')
-rw-r--r--azalea-client/src/local_player.rs9
1 files changed, 4 insertions, 5 deletions
diff --git a/azalea-client/src/local_player.rs b/azalea-client/src/local_player.rs
index bf3f18f1..8298cf0a 100644
--- a/azalea-client/src/local_player.rs
+++ b/azalea-client/src/local_player.rs
@@ -112,12 +112,11 @@ impl LocalPlayer {
.send(packet)
.expect("write_packet shouldn't be able to be called if the connection is closed");
}
+}
- /// Disconnect this client from the server by ending all tasks.
- ///
- /// The OwnedReadHalf for the TCP connection is in one of the tasks, so it
- /// automatically closes the connection when that's dropped.
- pub fn disconnect(&self) {
+impl Drop for LocalPlayer {
+ /// Stop every active task when the `LocalPlayer` is dropped.
+ fn drop(&mut self) {
for task in &self.tasks {
task.abort();
}