diff options
author | tom barrett <spalf0@gmail.com> | 2018-02-22 07:08:36 -0600 |
---|---|---|
committer | tom barrett <spalf0@gmail.com> | 2018-02-22 07:08:36 -0600 |
commit | 839f8a7a260276973f41a2c5a6e9d138518d7072 (patch) | |
tree | 629dec47604a83251fde775d60b57302a526683d /src | |
parent | c8d308a566c9e3e5be85e0e67082a06c3420a72b (diff) |
-believe found a way to tell if connection has closed
Diffstat (limited to 'src')
-rw-r--r-- | src/connection.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/connection.rs b/src/connection.rs index b84c4e8..5c086fa 100644 --- a/src/connection.rs +++ b/src/connection.rs @@ -67,16 +67,20 @@ impl Connection { let mut location = masses[self.index].get_location(); let mut data = String::new(); match self.buff_r.read_line(&mut data) { - Ok(_result) => match data.as_bytes() { + Ok(result) => match data.as_bytes() { b"5\n" => location.0 += 1, b"0\n" => location.0 -= 1, b"8\n" => location.1 += 1, b"2\n" => location.1 -= 1, b"4\n" => location.2 += 1, b"6\n" => location.2 -= 1, - _ => (), + _ => { + if result == 0 { + self.open = false; + } + }, }, - Err(_error) => println!("b{}", _error) + Err(_error) => (), } masses[self.index].give_location(location); } |