Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
callmeclover authored Apr 29, 2024
1 parent bdbbe80 commit 744266b
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ lazy_static::lazy_static! {
// Our shared state
struct AppState {
// We require unique usernames. This tracks which usernames have been taken.
user_set: Arc<Mutex<Vec<String>>>,
user_set: Arc<Mutex<HashSet<String>>>,
// Channel used to send messages to all connected clients.
tx: broadcast::Sender<String>,
}
Expand Down Expand Up @@ -193,7 +193,5 @@ async fn handle_socket(socket: WebSocket, _who: SocketAddr, state: Arc<AppState>
);

*USER_ID.lock().unwrap() -= 1;
if (state.user_set.lock().unwrap().contains(user.lock().unwrap().name.clone())) {
state.user_set.lock().unwrap().swap_remove(state.user_set.lock().unwrap().iter().position(|&r| r == user.lock().unwrap().name.clone()).unwrap());
}
state.user_set.lock().unwrap().remove(&user.lock().unwrap().name.clone());
}

0 comments on commit 744266b

Please sign in to comment.