From 4bacc355519fd2039c75e803514b4ee42a61ab87 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sun, 30 Mar 2025 16:44:07 -0400 Subject: [PATCH] Remove separate InternalMsg enum I think the current way I'll accomplish this for now is to use the other task to send all messages from the global server state back into the main connection loop. --- src/bin/kawari-world.rs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/bin/kawari-world.rs b/src/bin/kawari-world.rs index 367d05d..f8026c1 100644 --- a/src/bin/kawari-world.rs +++ b/src/bin/kawari-world.rs @@ -117,11 +117,6 @@ struct ClientData { connection: ZoneConnection, } -#[derive(Debug)] -enum InternalMsg { - Message(String), -} - /// Spawn a new client actor. pub fn spawn_client(info: ZoneConnection) { let (send, recv) = channel(64); @@ -173,13 +168,11 @@ async fn start_client(my_handle: oneshot::Receiver, mut data: Clie async fn client_server_loop( mut data: Receiver, - internal_send: UnboundedSender, + internal_send: UnboundedSender, ) { loop { match data.recv().await { - Some(msg) => match msg { - FromServer::Message(msg) => internal_send.send(InternalMsg::Message(msg)).unwrap(), - }, + Some(msg) => internal_send.send(msg).unwrap(), None => break, } } @@ -187,7 +180,7 @@ async fn client_server_loop( async fn client_loop( mut connection: ZoneConnection, - mut internal_recv: UnboundedReceiver, + mut internal_recv: UnboundedReceiver, ) { let database = connection.database.clone(); let game_data = connection.gamedata.clone(); @@ -1023,7 +1016,7 @@ async fn client_loop( } msg = internal_recv.recv() => match msg { Some(msg) => match msg { - InternalMsg::Message(msg) => connection.send_message(&msg).await, + FromServer::Message(msg) => connection.send_message(&msg).await, }, None => break, }