whoops the fix made your user duplicate
This commit is contained in:
parent
c77a44f596
commit
1a1e56aef0
1 changed files with 13 additions and 9 deletions
22
src/main.rs
22
src/main.rs
|
@ -159,14 +159,6 @@ fn handle_client(mut stream: TcpStream, channel: Channel) {
|
|||
token: format!("{:x}", random::random::<u128>()),
|
||||
};
|
||||
|
||||
for usr in &mut channel.lock().unwrap().online_users {
|
||||
if usr.name == user.name {
|
||||
usr.status = user.status.clone();
|
||||
usr.token = user.token.clone();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
stream
|
||||
.write_fmt(format_args!(
|
||||
"\x1b[0m\x1b[32;1mYour token to rejoin after quitting is {}.\x1b[0m\n",
|
||||
|
@ -180,7 +172,19 @@ fn handle_client(mut stream: TcpStream, channel: Channel) {
|
|||
token: "".to_owned(),
|
||||
};
|
||||
|
||||
channel.lock().unwrap().online_users.push(user.clone());
|
||||
let mut broke = false;
|
||||
for usr in &mut channel.lock().unwrap().online_users {
|
||||
if usr.name == user.name {
|
||||
usr.status = user.status.clone();
|
||||
usr.token = user.token.clone();
|
||||
broke = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if !broke {
|
||||
channel.lock().unwrap().online_users.push(user.clone());
|
||||
}
|
||||
|
||||
let (recieve_terminate_send, recieve_terminate_recv) = std::sync::mpsc::channel::<()>();
|
||||
let recieve_thread: JoinHandle<_>;
|
||||
|
|
Loading…
Add table
Reference in a new issue