fn send_to_other_player(users: &Users, new_msg: &str) {
    //info!("send_to_other_player: {}", new_msg);
    //the other user is in the other_ws_uid field

    //serde_json knows: 1. map (key+value pair) and 2. array
    let json_map: serde_json::Map<String, serde_json::Value> =
        serde_json::from_str(new_msg).expect("error serde_json::from_str(new_msg)");
    //info!("js_other_ws_uid: {}", v);
    let tuple = json_map
        .iter()
        .next()
        .expect("error json_map.iter().next()");

    let object = tuple.1;
    info!("object: {}", object);

    let js_other_ws_uid = object
        .get("other_ws_uid")
        .expect("error object.get(other_ws_uid)");
    info!("js_other_ws_uid: {}", js_other_ws_uid);

    let i64_other_ws_uid = js_other_ws_uid.as_i64().expect("js_other_ws_uid.as_i64()");
    info!("i64_other_ws_uid: {}", i64_other_ws_uid);
    let other_ws_uid =
        usize::try_from(i64_other_ws_uid).expect("usize::try_from(i64_other_ws_uid)");

    match users
        .lock()
        .expect("error users.lock()")
        .get(&other_ws_uid)
        .unwrap()
        .unbounded_send(Message::text(String::from(new_msg)))
    {
        Ok(()) => (),
        Err(_disconnected) => {}
    }
}
///New message from this user send only to the other player.
New message from this user send only to the other player.
New message from this user send only to the other player .
fn send_to_other_player(users: &Users, new_msg: &str) {
    //info!("send_to_other_player: {}", new_msg);
    //the other user is in the other_ws_uid field
    //serde_json knows: 1. map (key+value pair) and 2. array
    let json_map: serde_json::Map<String, serde_json::Value> =
        serde_json::from_str(new_msg).expect("error serde_json::from_str(new_msg)");
    //info!("js_other_ws_uid: {}", v);
    let tuple = json_map
        .iter()
        .next()
        .expect("error json_map.iter().next()");
    let object = tuple.1;
    info!("object: {}", object);
    let js_other_ws_uid = object
        .get("other_ws_uid")
        .expect("error object.get(other_ws_uid)");
    info!("js_other_ws_uid: {}", js_other_ws_uid);
    let i64_other_ws_uid = js_other_ws_uid.as_i64().expect("js_other_ws_uid.as_i64()");
    info!("i64_other_ws_uid: {}", i64_other_ws_uid);
    let other_ws_uid =
        usize::try_from(i64_other_ws_uid).expect("usize::try_from(i64_other_ws_uid)");
    match users
        .lock()
        .expect("error users.lock()")
        .get(&other_ws_uid)
        .unwrap()
        .unbounded_send(Message::text(String::from(new_msg)))
    {
        Ok(()) => (),
        Err(_disconnected) => {}
    }
}
fn send_to_other_player ( users : & Users , new_msg : & str ) { //info!("send_to_other_player: {}", new_msg); //the other user is in the other_ws_uid field //serde_json knows: 1. map (key+value pair) and 2. array let json_map : serde_json :: Map < String , serde_json :: Value > = serde_json :: from_str ( new_msg ) . expect ( " " ) ; //info!("js_other_ws_uid: {}", v); let tuple = json_map . iter ( ) . next ( ) . expect ( " " ) ; let object = tuple . 1 ; info ! ( " " object ) ; let js_other_ws_uid = object . get ( " " ) . expect ( " " ) ; info ! ( " " js_other_ws_uid ) ; let i64_other_ws_uid = js_other_ws_uid . as_i64 ( ) . expect ( " " ) ; info ! ( " " i64_other_ws_uid ) ; let other_ws_uid = usize :: try_from ( i64_other_ws_uid ) . expect ( " " ) ; match users . lock ( ) . expect ( " " ) . get ( & other_ws_uid ) . unwrap ( ) . unbounded_send ( Message :: text ( String :: from ( new_msg ) ) ) { Ok ( ( ) ) => ( ) , Err ( _disconnected ) => { } } }
New message from this user send only to the other player.
New message from this user send only to the other player .
users
&Users
new_msg
&str