async fn insert_client_into_given_session(
  client_id: &str,
  clients: &data_types::SafeClients,
  session: &mut session_types::Session,
) {
  // add client to session
  session.insert_client(client_id, true);
  // update session_id of client
  if let Some(client) = clients.write().await.get_mut(client_id) {
    client.session_id = Some(session.id.clone());
  }
  // notify all clients in the session that the client has joined
  notify_session(
    &shared_types::ServerEvent::from_event(
      shared_types::ServerEventCode::ClientJoined,
      shared_types::ServerEventData {
        session_id: Some(session.id.clone()),
        client_id: Some(client_id.to_string()),
        session_client_ids: Some(session.get_client_ids()),
        game_data: None,
        player_data: None,
      },
    ),
    &session,
    &clients,
  )
  .await;
}
/// Takes a mutable session reference in order to add a client to a given session
///
/// Uses a Read lock for Clients

Takes a mutable session reference in order to add a client to a given session
Uses a Read lock for Clients
Takes a mutable session reference in order to add a client to a given session Uses a Read lock for Clients
async fn insert_client_into_given_session(
  client_id: &str,
  clients: &data_types::SafeClients,
  session: &mut session_types::Session,
) {
  // add client to session
  session.insert_client(client_id, true);
  // update session_id of client
  if let Some(client) = clients.write().await.get_mut(client_id) {
    client.session_id = Some(session.id.clone());
  }
  // notify all clients in the session that the client has joined
  notify_session(
    &shared_types::ServerEvent::from_event(
      shared_types::ServerEventCode::ClientJoined,
      shared_types::ServerEventData {
        session_id: Some(session.id.clone()),
        client_id: Some(client_id.to_string()),
        session_client_ids: Some(session.get_client_ids()),
        game_data: None,
        player_data: None,
      },
    ),
    &session,
    &clients,
  )
  .await;
}
async fn insert_client_into_given_session ( client_id : & str , clients : & data_types :: SafeClients , session : & mut session_types :: Session , ) { // add client to session
 session . insert_client ( client_id , true ) ; // update session_id of client
 if let Some ( client ) = clients . write ( ) . await . get_mut ( client_id ) { client . session_id = Some ( session . id . clone ( ) ) ; } // notify all clients in the session that the client has joined
 notify_session ( & shared_types :: ServerEvent :: from_event ( shared_types :: ServerEventCode :: ClientJoined , shared_types :: ServerEventData { session_id : Some ( session . id . clone ( ) ) , client_id : Some ( client_id . to_string ( ) ) , session_client_ids : Some ( session . get_client_ids ( ) ) , game_data : None , player_data : None , } , ) , & session , & clients , ) . await ; }
Takes a mutable session reference in order to add a client to a given session
Uses a Read lock for Clients
Takes a mutable session reference in order to add a client to a given session Uses a Read lock for Clients
client_id
&str
clients
&data_types::SafeClients
session
&mut session_types::Session
client_id
&str
clients
&data_types::SafeClients
session
&mut session_types::Session