|
|
|
@ -18,7 +18,9 @@ fn handle_connection(stream: TcpStream, prot: &mut protocol::Protocol) -> Result |
|
|
|
let len = match reader.read_line(&mut text) { |
|
|
|
Ok(len) => len, |
|
|
|
Err(_) => { |
|
|
|
if protocol::DEBUG { |
|
|
|
println!("Reading line from client failed!"); |
|
|
|
} |
|
|
|
0 |
|
|
|
}, |
|
|
|
}; |
|
|
|
@ -26,14 +28,18 @@ fn handle_connection(stream: TcpStream, prot: &mut protocol::Protocol) -> Result |
|
|
|
if len == 0 { |
|
|
|
break; |
|
|
|
} |
|
|
|
if protocol::DEBUG { |
|
|
|
println!("read: {}", text); |
|
|
|
} |
|
|
|
match prot.parse(&text) { |
|
|
|
Ok(response) => { |
|
|
|
match writeln!(outstream,"{}",response) { |
|
|
|
Ok(_) => (), |
|
|
|
Err(_) => { |
|
|
|
prot.stop(); |
|
|
|
println!("Write to TCP Stream failed") |
|
|
|
if protocol::DEBUG { |
|
|
|
println!("Write to TCP Stream failed"); |
|
|
|
} |
|
|
|
}, |
|
|
|
} |
|
|
|
}, |
|
|
|
@ -42,7 +48,9 @@ fn handle_connection(stream: TcpStream, prot: &mut protocol::Protocol) -> Result |
|
|
|
Ok(_) => (), |
|
|
|
Err(_) => { |
|
|
|
prot.stop(); |
|
|
|
println!("Write to TCP Stream failed") |
|
|
|
if protocol::DEBUG { |
|
|
|
println!("Write to TCP Stream failed"); |
|
|
|
} |
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|
|