async fn handle_game_event(&self, id: PlayerId, event_type: GameEvent) -> Result<()> {
        tracing::trace!("Handling game event: {:?}", event_type);

        match event_type {
            GameEvent::Accepted(response) => {
                self.to_client(id, GameEvent::Accepted(response)).await?;
            }
            GameEvent::Command(response) => match &response {
                Response::Channel(here, _) => {
                    self.broadcast(here.to_vec(), GameEvent::Command(response))
                        .await?;
                }
                _ => self.to_client(id, GameEvent::Command(response)).await?,
            },
            GameEvent::Pong(response) => {
                self.to_client(id, GameEvent::Pong(response)).await?;
            }
            GameEvent::Save(mut player) => {
                player.save(self.pg.clone()).await;
            }
            GameEvent::GlobalSave(players) => {
                for mut player in players {
                    player.save(self.pg.clone()).await;
                }
            }
        }
        Ok(())
    }
/// Processes game events from the game thread and invokes the correct passing function.
Processes game events from the game thread and invokes the correct passing function.
Processes game events from the game thread and invokes the correct passing function .
async fn handle_game_event(&self, id: PlayerId, event_type: GameEvent) -> Result<()> {
        tracing::trace!("Handling game event: {:?}", event_type);
        match event_type {
            GameEvent::Accepted(response) => {
                self.to_client(id, GameEvent::Accepted(response)).await?;
            }
            GameEvent::Command(response) => match &response {
                Response::Channel(here, _) => {
                    self.broadcast(here.to_vec(), GameEvent::Command(response))
                        .await?;
                }
                _ => self.to_client(id, GameEvent::Command(response)).await?,
            },
            GameEvent::Pong(response) => {
                self.to_client(id, GameEvent::Pong(response)).await?;
            }
            GameEvent::Save(mut player) => {
                player.save(self.pg.clone()).await;
            }
            GameEvent::GlobalSave(players) => {
                for mut player in players {
                    player.save(self.pg.clone()).await;
                }
            }
        }
        Ok(())
    }
async fn handle_game_event ( & self , id : PlayerId , event_type : GameEvent ) -> Result < ( ) > { tracing :: trace ! ( " " event_type ) ; match event_type { GameEvent :: Accepted ( response ) => { self . to_client ( id , GameEvent :: Accepted ( response ) ) . await ? ; } GameEvent :: Command ( response ) => match & response { Response :: Channel ( here , _ ) => { self . broadcast ( here . to_vec ( ) , GameEvent :: Command ( response ) ) . await ? ; } _ => self . to_client ( id , GameEvent :: Command ( response ) ) . await ? , } , GameEvent :: Pong ( response ) => { self . to_client ( id , GameEvent :: Pong ( response ) ) . await ? ; } GameEvent :: Save ( mut player ) => { player . save ( self . pg . clone ( ) ) . await ; } GameEvent :: GlobalSave ( players ) => { for mut player in players { player . save ( self . pg . clone ( ) ) . await ; } } } Ok ( ( ) ) }
Processes game events from the game thread and invokes the correct passing function.
Processes game events from the game thread and invokes the correct passing function .
&self
id
PlayerId
event_type
GameEvent
&self
id
PlayerId
event_type
GameEvent