Compare commits
2 commits
Author | SHA1 | Date | |
---|---|---|---|
1a1e56aef0 | |||
c77a44f596 |
1 changed files with 13 additions and 9 deletions
20
src/main.rs
20
src/main.rs
|
@ -119,14 +119,6 @@ fn handle_client(mut stream: TcpStream, channel: Channel) {
|
|||
if user.token != String::from_utf8_lossy(&(buf[..i])) {
|
||||
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;
|
||||
}
|
||||
if i < 50 {
|
||||
|
@ -180,7 +172,19 @@ fn handle_client(mut stream: TcpStream, channel: Channel) {
|
|||
token: "".to_owned(),
|
||||
};
|
||||
|
||||
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