fix: send cloned user

wasteful but eh prototype!
This commit is contained in:
əlemi 2024-02-21 20:05:12 +01:00
parent 51b6d8c301
commit 425fa62213
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -136,11 +136,12 @@ impl Session {
Ok(proto::Packet::UserState(user)) => {
tracing::info!("user state: {:?}", user);
let mut users = session.users.write().await;
match users.get_mut(&user.session()) {
let id = user.session();
match users.get_mut(&id) {
Some(u) => u.update(user),
None => { users.insert(user.session(), User::from(user)); },
}
let _ = session.events.send(users.get(&user.session()).expect("just inserted")); // if it fails nobody is listening
let _ = session.events.send(users.get(&id).cloned().expect("just inserted")); // if it fails nobody is listening
},
Ok(pkt) => tracing::info!("ignoring packet {:?}", pkt),
}