diff options
| author | mat <git@matdoes.dev> | 2026-03-28 15:28:47 -0630 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2026-03-28 15:28:47 -0630 |
| commit | ed12c2dd3608588cc5a6c1ee250735bb0414de7f (patch) | |
| tree | 354f60826cb24dab8ec9de3d220ae525e1127138 | |
| parent | 999bde91394f4f3f33f9c6ae9a885bc0da60e1a4 (diff) | |
| download | azalea-drasl-ed12c2dd3608588cc5a6c1ee250735bb0414de7f.tar.xz | |
add StartClientOpts::new_with_appexit_rx
| -rw-r--r-- | azalea/src/client_impl/mod.rs | 35 | ||||
| -rw-r--r-- | azalea/src/lib.rs | 6 |
2 files changed, 27 insertions, 14 deletions
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<mpsc::UnboundedSender<Event>>, ) -> StartClientOpts { + Self::new_with_appexit_rx(account, address, event_sender).0 + } + + pub fn new_with_appexit_rx( + account: Account, + address: ResolvedAddr, + event_sender: Option<mpsc::UnboundedSender<Event>>, + ) -> (StartClientOpts, oneshot::Receiver<AppExit>) { 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 diff --git a/azalea/src/lib.rs b/azalea/src/lib.rs index 1ce7e5e6..3be74b9e 100644 --- a/azalea/src/lib.rs +++ b/azalea/src/lib.rs @@ -56,7 +56,11 @@ pub use builder::ClientBuilder; use futures::future::BoxFuture; pub use join_opts::JoinOpts; -pub use crate::{client_impl::Client, entity_ref::EntityRef, events::Event}; +pub use crate::{ + client_impl::{Client, StartClientOpts}, + entity_ref::EntityRef, + events::Event, +}; pub type BoxHandleFn<S, R> = Box<dyn Fn(Client, Event, S) -> BoxFuture<'static, R> + Send>; pub type HandleFn<S, Fut> = fn(Client, Event, S) -> Fut; |
