From 425fa622136145b6891b697f7a975210e860d8e9 Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 21 Feb 2024 20:05:12 +0100 Subject: [PATCH] fix: send cloned user wasteful but eh prototype! --- src/session.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/session.rs b/src/session.rs index 0d72237..466e966 100644 --- a/src/session.rs +++ b/src/session.rs @@ -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), }