Fixed request 4.2.2 in server

This commit is contained in:
Phuntsok Drak-pa 2018-03-21 23:23:14 +01:00
parent 76c8ece29a
commit ff88e2133d

View File

@ -88,16 +88,13 @@ fn distribute_message(
fn send_clients_name(to: &SocketAddr, lock: &mut MutexGuard<UserMap>) {
let mut clients = String::new();
for (client, entry) in (*lock).iter() {
&entry.0.trim_left();
&entry.0.trim_right();
clients.push_str(&format!(
"{}{} ",
if client == to { "(You)" } else { "" },
&entry.0
&entry.0.trim(),
if client == to { "(you)" } else { "" }
));
}
clients.trim_left();
println!("{}", clients);
let clients = clients.trim();
for (client, entry) in (*lock).iter() {
if client == to {
let stream = &entry.1;