Nicely close connections for dropped clients

This commit is contained in:
timvisee
2018-03-14 15:53:21 +01:00
parent f0d2513d87
commit f11bc8cf00
2 changed files with 9 additions and 2 deletions

View File

@@ -112,14 +112,14 @@ impl<'a: 'b, 'b> ArgHandler<'a> {
pub fn size(&self, def: Option<(u32, u32)>) -> (u32, u32) { pub fn size(&self, def: Option<(u32, u32)>) -> (u32, u32) {
( (
self.matches.value_of("width") self.matches.value_of("width")
.map(|width| width.parse::<u32>() .map(|width| width.parse()
.expect("Invalid image width") .expect("Invalid image width")
) )
.unwrap_or( .unwrap_or(
def.expect("No screen width set or known").0 def.expect("No screen width set or known").0
), ),
self.matches.value_of("height") self.matches.value_of("height")
.map(|height| height.parse::<u32>() .map(|height| height.parse()
.expect("Invalid image height") .expect("Invalid image height")
) )
.unwrap_or( .unwrap_or(

View File

@@ -117,6 +117,13 @@ impl Client {
} }
} }
impl Drop for Client {
/// Nicely drop the connection when the client is disconnected.
fn drop(&mut self) {
let _ = self.write_command("\r\nQUIT".into());
}
}
/// Create a stream to talk to the pixelflut server. /// Create a stream to talk to the pixelflut server.