maybe fix bug with rejoining
This commit is contained in:
parent
541abd1d6a
commit
c77a44f596
1 changed files with 8 additions and 8 deletions
16
src/main.rs
16
src/main.rs
|
@ -119,14 +119,6 @@ fn handle_client(mut stream: TcpStream, channel: Channel) {
|
||||||
if user.token != String::from_utf8_lossy(&(buf[..i])) {
|
if user.token != String::from_utf8_lossy(&(buf[..i])) {
|
||||||
break 'bufreadloop2;
|
break 'bufreadloop2;
|
||||||
}
|
}
|
||||||
let mut i = 0usize;
|
|
||||||
for user in &channel.lock().unwrap().online_users {
|
|
||||||
if user.name == new_name {
|
|
||||||
channel.lock().unwrap().online_users.swap_remove(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
i += 1;
|
|
||||||
}
|
|
||||||
break 'bufreadloop;
|
break 'bufreadloop;
|
||||||
}
|
}
|
||||||
if i < 50 {
|
if i < 50 {
|
||||||
|
@ -167,6 +159,14 @@ fn handle_client(mut stream: TcpStream, channel: Channel) {
|
||||||
token: format!("{:x}", random::random::<u128>()),
|
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
|
stream
|
||||||
.write_fmt(format_args!(
|
.write_fmt(format_args!(
|
||||||
"\x1b[0m\x1b[32;1mYour token to rejoin after quitting is {}.\x1b[0m\n",
|
"\x1b[0m\x1b[32;1mYour token to rejoin after quitting is {}.\x1b[0m\n",
|
||||||
|
|
Loading…
Add table
Reference in a new issue