From 9a40b65bc1912298a43de43fd6e8477a8622a832 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Fri, 2 May 2025 15:55:58 -0500 Subject: Add AutoReconnectPlugin (#221) * add AutoReconnectPlugin * merge main * start simplifying swarm internals * fix Swarm::into_iter, handler functions, DisconnectEvent, and add some more docs * add ClientBuilder/SwarmBuilder::reconnect_after * fix a doctest * reword SwarmEvent::Disconnect doc * better behavior when we try to join twice * reconnect on ConnectionFailedEvent too * autoreconnect is less breaking now --- azalea/examples/testbot/main.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'azalea/examples') diff --git a/azalea/examples/testbot/main.rs b/azalea/examples/testbot/main.rs index c25904cf..6733d797 100644 --- a/azalea/examples/testbot/main.rs +++ b/azalea/examples/testbot/main.rs @@ -192,14 +192,10 @@ async fn handle(bot: Client, event: azalea::Event, state: State) -> anyhow::Resu Ok(()) } -async fn swarm_handle(swarm: Swarm, event: SwarmEvent, _state: SwarmState) -> anyhow::Result<()> { +async fn swarm_handle(_swarm: Swarm, event: SwarmEvent, _state: SwarmState) -> anyhow::Result<()> { match &event { - SwarmEvent::Disconnect(account, join_opts) => { + SwarmEvent::Disconnect(account, _join_opts) => { println!("bot got kicked! {}", account.username); - tokio::time::sleep(Duration::from_secs(5)).await; - swarm - .add_and_retry_forever_with_opts(account, State::default(), join_opts) - .await; } SwarmEvent::Chat(chat) => { if chat.message().to_string() == "The particle was not visible for anybody" { -- cgit v1.2.3