From d42a28c46057c386d161bfe438302e2314f0a6f6 Mon Sep 17 00:00:00 2001 From: tom barrett Date: Wed, 21 Feb 2018 06:27:02 -0600 Subject: -got engine and dashboard data sending --- src/bin/server.rs | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'src/bin/server.rs') diff --git a/src/bin/server.rs b/src/bin/server.rs index 71541f8..871315e 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -1,24 +1,27 @@ -use std::io::prelude::*; -use std::net::{TcpListener, TcpStream}; +use std::thread::sleep; +use std::time::Duration; +use std::net::TcpListener; extern crate space; use space::connection::Connection; fn main() { let listener = TcpListener::bind("localhost:6000").unwrap(); - listener.set_nonblocking(true); + listener.set_nonblocking(true).unwrap(); let mut connections = Vec::new(); - loop { - for stream in listener.incoming() { - match stream { - Ok(stream) => connections.push(Connection::new(stream)), - _ => (), + for stream in listener.incoming() { + match stream { + Ok(stream) => connections.push(Connection::new(stream)), + _ => { + println!("looped"); + for i in 0..connections.len() { + connections[i].process(); + } + connections.retain(|connection| connection.open ); + sleep(Duration::from_millis(100)); } - for i in 0..connections.len() { - connections[i].process(); - } - connections.retain(|connection| connection.open ); } } + } -- cgit v1.2.3