mirror of
https://git.alemi.dev/mumble-stats-api.git
synced 2024-11-14 04:29:19 +01:00
fix: actually update users
This commit is contained in:
parent
7f0516dd1e
commit
6cb230d75c
1 changed files with 12 additions and 6 deletions
|
@ -104,7 +104,8 @@ impl Session {
|
|||
let (ready, sync) = watch::channel(false);
|
||||
|
||||
let s = Arc::new(Session {
|
||||
username, drop, sync,
|
||||
drop, sync,
|
||||
username: username.clone(),
|
||||
users : RwLock::new(HashMap::new()),
|
||||
host: host.to_string(),
|
||||
});
|
||||
|
@ -122,14 +123,19 @@ impl Session {
|
|||
Err(e) => break tracing::warn!("disconnected from server: {}", e),
|
||||
// Ok(tcp::proto::Packet::TextMessage(msg)) => tracing::info!("{}", msg.message),
|
||||
// Ok(tcp::proto::Packet::ChannelState(channel)) => tracing::info!("discovered channel: {:?}", channel.name),
|
||||
Ok(proto::Packet::ServerSync(_sync)) => ready_tx.send(true).unwrap(),
|
||||
Ok(proto::Packet::ServerSync(_sync)) => {
|
||||
tracing::info!("synched: {:?}", _sync);
|
||||
ready.send(true).unwrap();
|
||||
},
|
||||
Ok(proto::Packet::UserState(user)) => {
|
||||
tracing::info!("user state: {:#?}", user);
|
||||
if user.name.as_ref().is_some_and(|n| n != &username) {
|
||||
session.users.write().await.insert(user.user_id(), User::from(user));
|
||||
tracing::info!("user state: {:?}", user);
|
||||
let mut users = session.users.write().await;
|
||||
match users.get_mut(&user.session()) {
|
||||
Some(u) => u.update(user),
|
||||
None => { users.insert(user.session(), User::from(user)); },
|
||||
}
|
||||
},
|
||||
Ok(pkt) => tracing::debug!("ignoring packet {:#?}", pkt),
|
||||
Ok(pkt) => tracing::info!("ignoring packet {:?}", pkt),
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue