async fn handle_client_event(&self, id: i32, event_type: ClientEvent) -> Result<()> {
        tracing::trace!("Handling client event: {:?}", event_type);

        match event_type {
            ClientEvent::Connect(player, tx) => {
                // We know the tx will always be Some, because we ONLY send a Some value. However,
                // because the game should NOT know about the peer connection or have its send
                // channel, we need to make this an option so we can forward as a None.
                self.tx_peers
                    .insert(id, tx.expect("This should never happen."));
                self.to_game(id, ClientEvent::Connect(player, None)).await?;
            }
            ClientEvent::Command(msg) => {
                self.to_game(id, ClientEvent::Command(msg)).await?;
            }
            ClientEvent::Ping => {
                self.to_game(id, ClientEvent::Ping).await?;
            }
            ClientEvent::Disconnect => {
                self.to_game(id, ClientEvent::Disconnect).await?;
                self.tx_peers.remove(&id);
            }
        }
        Ok(())
    }
/// Processes client events from the connection pool and passes them to the game thread.
Processes client events from the connection pool and passes them to the game thread.
Processes client events from the connection pool and passes them to the game thread .
async fn handle_client_event(&self, id: i32, event_type: ClientEvent) -> Result<()> {
        tracing::trace!("Handling client event: {:?}", event_type);
        match event_type {
            ClientEvent::Connect(player, tx) => {
                // We know the tx will always be Some, because we ONLY send a Some value. However,
                // because the game should NOT know about the peer connection or have its send
                // channel, we need to make this an option so we can forward as a None.
                self.tx_peers
                    .insert(id, tx.expect("This should never happen."));
                self.to_game(id, ClientEvent::Connect(player, None)).await?;
            }
            ClientEvent::Command(msg) => {
                self.to_game(id, ClientEvent::Command(msg)).await?;
            }
            ClientEvent::Ping => {
                self.to_game(id, ClientEvent::Ping).await?;
            }
            ClientEvent::Disconnect => {
                self.to_game(id, ClientEvent::Disconnect).await?;
                self.tx_peers.remove(&id);
            }
        }
        Ok(())
    }
async fn handle_client_event ( & self , id : i32 , event_type : ClientEvent ) -> Result < ( ) > { tracing :: trace ! ( " " event_type ) ; match event_type { ClientEvent :: Connect ( player , tx ) => { // We know the tx will always be Some, because we ONLY send a Some value. However, // because the game should NOT know about the peer connection or have its send // channel, we need to make this an option so we can forward as a None. self . tx_peers . insert ( id , tx . expect ( " " ) ) ; self . to_game ( id , ClientEvent :: Connect ( player , None ) ) . await ? ; } ClientEvent :: Command ( msg ) => { self . to_game ( id , ClientEvent :: Command ( msg ) ) . await ? ; } ClientEvent :: Ping => { self . to_game ( id , ClientEvent :: Ping ) . await ? ; } ClientEvent :: Disconnect => { self . to_game ( id , ClientEvent :: Disconnect ) . await ? ; self . tx_peers . remove ( & id ) ; } } Ok ( ( ) ) }
Processes client events from the connection pool and passes them to the game thread.
Processes client events from the connection pool and passes them to the game thread .
&self
id
i32
event_type
ClientEvent
&self
id
i32
event_type
ClientEvent