From ed12c2dd3608588cc5a6c1ee250735bb0414de7f Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 28 Mar 2026 15:28:47 -0630 Subject: add StartClientOpts::new_with_appexit_rx --- azalea/src/client_impl/mod.rs | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'azalea/src/client_impl') diff --git a/azalea/src/client_impl/mod.rs b/azalea/src/client_impl/mod.rs index 45b11fbf..be711ef1 100644 --- a/azalea/src/client_impl/mod.rs +++ b/azalea/src/client_impl/mod.rs @@ -29,7 +29,7 @@ use azalea_world::{PartialWorld, World, WorldName}; use bevy_app::{App, AppExit}; use bevy_ecs::{entity::Entity, resource::Resource, world::Mut}; use parking_lot::RwLock; -use tokio::sync::mpsc; +use tokio::sync::{mpsc, oneshot}; use uuid::Uuid; use crate::{ @@ -87,24 +87,33 @@ impl StartClientOpts { address: ResolvedAddr, event_sender: Option>, ) -> StartClientOpts { + Self::new_with_appexit_rx(account, address, event_sender).0 + } + + pub fn new_with_appexit_rx( + account: Account, + address: ResolvedAddr, + event_sender: Option>, + ) -> (StartClientOpts, oneshot::Receiver) { let mut app = App::new(); app.add_plugins((DefaultPlugins, DefaultBotPlugins, DefaultSwarmPlugins)); - // appexit_rx is unused here since the user should be able to handle it - // themselves if they're using StartClientOpts::new - let (ecs_lock, start_running_systems, _appexit_rx) = start_ecs_runner(app.main_mut()); + let (ecs_lock, start_running_systems, appexit_rx) = start_ecs_runner(app.main_mut()); start_running_systems(); - Self { - ecs_lock, - account, - connect_opts: ConnectOpts { - address, - server_proxy: None, - sessionserver_proxy: None, + ( + Self { + ecs_lock, + account, + connect_opts: ConnectOpts { + address, + server_proxy: None, + sessionserver_proxy: None, + }, + event_sender, }, - event_sender, - } + appexit_rx, + ) } /// Configure the SOCKS5 proxy used for connecting to the server and for -- cgit v1.2.3