Compare commits
No commits in common. "main" and "v1.0.0" have entirely different histories.
1 changed files with 9 additions and 13 deletions
20
src/main.rs
20
src/main.rs
|
@ -119,6 +119,14 @@ 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 {
|
||||||
|
@ -172,19 +180,7 @@ fn handle_client(mut stream: TcpStream, channel: Channel) {
|
||||||
token: "".to_owned(),
|
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());
|
channel.lock().unwrap().online_users.push(user.clone());
|
||||||
}
|
|
||||||
|
|
||||||
let (recieve_terminate_send, recieve_terminate_recv) = std::sync::mpsc::channel::<()>();
|
let (recieve_terminate_send, recieve_terminate_recv) = std::sync::mpsc::channel::<()>();
|
||||||
let recieve_thread: JoinHandle<_>;
|
let recieve_thread: JoinHandle<_>;
|
||||||
|
|
Loading…
Add table
Reference in a new issue