async fn remove_client_from_current_session(
  client_id: &str,
  clients: &data_types::SafeClients,
  sessions: &data_types::SafeSessions,
  game_states: &data_types::SafeGameStates,
) {
  let session_id: String = match get_client_session_id(client_id, clients).await {
    Some(s_id) => s_id,
    None => return, // client did not exist in any session
  };

  let mut session_empty: bool = false;
  if let Some(session) = sessions.write().await.get_mut(&session_id) {
    // notify all clients in the sessions that the client will be leaving
    notify_session(
      &shared_types::ServerEvent::from_event(
        shared_types::ServerEventCode::ClientLeft,
        shared_types::ServerEventData {
          session_id: None,
          client_id: Some(client_id.to_string()),
          session_client_ids: None,
          game_data: None,
          player_data: None,
        },
      ),
      &session,
      &clients,
    )
    .await;
    // remove the client from the session
    session.remove_client(&client_id.to_string());
    // revoke the client's copy of the session_id
    if let Some(client) = clients.write().await.get_mut(client_id) {
      client.session_id = None;
    }
    // checks the statuses to see if any users are still active
    session_empty = session.get_clients_with_active_status(true).is_empty();
    // if the session is not empty, make someone else the owner
    if !session_empty {
      set_new_session_owner(session, &clients, &session.get_client_ids()[0]);
    }
  }
  // clean up the session from the map if it is empty
  // * we cannot do this in the scope above because because we are already holding a mutable reference to a session within the map
  if session_empty {
    cleanup_session(&session_id, sessions, game_states).await;
  }
}
/// Removes a client from the session that they currently exist under

Removes a client from the session that they currently exist under
Removes a client from the session that they currently exist under
async fn remove_client_from_current_session(
  client_id: &str,
  clients: &data_types::SafeClients,
  sessions: &data_types::SafeSessions,
  game_states: &data_types::SafeGameStates,
) {
  let session_id: String = match get_client_session_id(client_id, clients).await {
    Some(s_id) => s_id,
    None => return, // client did not exist in any session
  };
  let mut session_empty: bool = false;
  if let Some(session) = sessions.write().await.get_mut(&session_id) {
    // notify all clients in the sessions that the client will be leaving
    notify_session(
      &shared_types::ServerEvent::from_event(
        shared_types::ServerEventCode::ClientLeft,
        shared_types::ServerEventData {
          session_id: None,
          client_id: Some(client_id.to_string()),
          session_client_ids: None,
          game_data: None,
          player_data: None,
        },
      ),
      &session,
      &clients,
    )
    .await;
    // remove the client from the session
    session.remove_client(&client_id.to_string());
    // revoke the client's copy of the session_id
    if let Some(client) = clients.write().await.get_mut(client_id) {
      client.session_id = None;
    }
    // checks the statuses to see if any users are still active
    session_empty = session.get_clients_with_active_status(true).is_empty();
    // if the session is not empty, make someone else the owner
    if !session_empty {
      set_new_session_owner(session, &clients, &session.get_client_ids()[0]);
    }
  }
  // clean up the session from the map if it is empty
  // * we cannot do this in the scope above because because we are already holding a mutable reference to a session within the map
  if session_empty {
    cleanup_session(&session_id, sessions, game_states).await;
  }
}
async fn remove_client_from_current_session ( client_id : & str , clients : & data_types :: SafeClients , sessions : & data_types :: SafeSessions , game_states : & data_types :: SafeGameStates , ) { let session_id : String = match get_client_session_id ( client_id , clients ) . await { Some ( s_id ) => s_id , None => return , // client did not exist in any session
 } ; let mut session_empty : bool = false ; if let Some ( session ) = sessions . write ( ) . await . get_mut ( & session_id ) { // notify all clients in the sessions that the client will be leaving
 notify_session ( & shared_types :: ServerEvent :: from_event ( shared_types :: ServerEventCode :: ClientLeft , shared_types :: ServerEventData { session_id : None , client_id : Some ( client_id . to_string ( ) ) , session_client_ids : None , game_data : None , player_data : None , } , ) , & session , & clients , ) . await ; // remove the client from the session
 session . remove_client ( & client_id . to_string ( ) ) ; // revoke the client's copy of the session_id
 if let Some ( client ) = clients . write ( ) . await . get_mut ( client_id ) { client . session_id = None ; } // checks the statuses to see if any users are still active
 session_empty = session . get_clients_with_active_status ( true ) . is_empty ( ) ; // if the session is not empty, make someone else the owner
 if ! session_empty { set_new_session_owner ( session , & clients , & session . get_client_ids ( ) [ 0 ] ) ; } } // clean up the session from the map if it is empty
 // * we cannot do this in the scope above because because we are already holding a mutable reference to a session within the map
 if session_empty { cleanup_session ( & session_id , sessions , game_states ) . await ; } }
Removes a client from the session that they currently exist under
Removes a client from the session that they currently exist under
client_id
&str
clients
&data_types::SafeClients
sessions
&data_types::SafeSessions
game_states
&data_types::SafeGameStates
client_id
&str
clients
&data_types::SafeClients
sessions
&data_types::SafeSessions
game_states
&data_types::SafeGameStates