known users can reconnect and rejoin games

This commit is contained in:
Adam 2024-08-22 14:05:56 -04:00
parent 77ac313070
commit 98921dbce1

View file

@ -192,6 +192,28 @@ impl UserHandler {
.unwrap()
.contains_key(&new_name)
{
// Copy over new tx
self.state
.offline_users
.read()
.unwrap()
.get(&new_name)
.unwrap()
.write()
.unwrap()
.tx = self
.state
.online_users
.read()
.unwrap()
.get(&addr)
.unwrap()
.read()
.unwrap()
.tx
.clone();
// Move offline user object to online
self.state
.online_users
.write()
@ -258,15 +280,6 @@ impl UserHandler {
.unwrap()
.change_name(username);
// send the user their new name
self.send_message_addr(
addr,
SendUserUpdate(UserUpdate {
username: new_name.clone(),
}),
)
.await;
// Send chat updates
let msg = format! {
"{0} changed name to {1}.",
@ -278,6 +291,15 @@ impl UserHandler {
.unwrap();
}
// Send the user their new name
self.send_message_addr(
addr,
SendUserUpdate(UserUpdate {
username: new_name.clone(),
}),
)
.await;
// Send client updates
broadcast_tx
.send(meta_games_browser_update(&self.state))