Compare commits
No commits in common. "520db4fe58fed1a603a80e32a8378f7ddbabfe8e" and "8ff51123523f9951558bce564dc15fc3ee211da7" have entirely different histories.
520db4fe58
...
8ff5112352
16
src/main.rs
16
src/main.rs
@ -101,20 +101,14 @@ async fn start_client(addr: &str) -> Result<(), Box<dyn Error>> {
|
||||
stream.write_all(username.trim().as_bytes()).await?;
|
||||
|
||||
println!("Connected to server at {}", addr);
|
||||
let mut input = String::new();
|
||||
loop {
|
||||
let mut input = String::new();
|
||||
reader.read_line(&mut input).await?;
|
||||
|
||||
let trimmed_input = input.trim();
|
||||
|
||||
if trimmed_input.is_empty() {
|
||||
println!("Empty message. Please enter a non-empty message.");
|
||||
continue;
|
||||
}
|
||||
|
||||
stream.write_all(trimmed_input.as_bytes()).await?;
|
||||
stream.write_all(input.trim().as_bytes()).await?;
|
||||
|
||||
// Print sent message
|
||||
println!("Sent message from {}: {}", username.trim(), trimmed_input);
|
||||
println!("Sent message from {}: {}", username.trim(), input.trim());
|
||||
input.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user