From 160d7b6e50df6d818f6882c033398d49193bd804 Mon Sep 17 00:00:00 2001 From: tom barrett Date: Mon, 5 Mar 2018 08:14:14 -0600 Subject: -brought back downcasting, moved connection functions inside the structure --- src/dashboard.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/dashboard.rs') diff --git a/src/dashboard.rs b/src/dashboard.rs index bfad542..c4c3200 100644 --- a/src/dashboard.rs +++ b/src/dashboard.rs @@ -5,7 +5,9 @@ use std::io::Write; extern crate serde_json; +use mass::Mass; use ship::Ship; +use connection::Connection; pub fn client_dashboard(mut buff_r : BufReader) { loop { @@ -16,10 +18,13 @@ pub fn client_dashboard(mut buff_r : BufReader) { } } -pub fn server_dashboard(mut ship_string : String, mut stream : &TcpStream) -> bool { - ship_string.push_str("\n"); - match stream.write(ship_string.as_bytes()) { - Ok(_result) => true, - Err(_error) => false, +impl Connection { + pub fn server_dashboard(&mut self, masses : &mut Vec>) -> bool { + let mut ship_string = masses[self.index].serialize(); + ship_string.push_str("\n"); + match self.stream.write(ship_string.as_bytes()) { + Ok(_result) => true, + Err(_error) => false, + } } } -- cgit v1.2.3