summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authortom barrett <spalf0@gmail.com>2018-06-14 10:18:22 -0500
committertom barrett <spalf0@gmail.com>2018-06-14 10:18:22 -0500
commit7094849bf164ff6f853c8f6812a0e831a66762f3 (patch)
tree9f553e799457ddc21317299d5c82facf63dc243b /src/bin
parent01fee8c1a2449a0d086a8bde42de1d61dbdc9231 (diff)
updated dependancies, made it so server still processes events if client connection is disconnected
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/server.rs17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/bin/server.rs b/src/bin/server.rs
index 1fad1d3..e20acf6 100644
--- a/src/bin/server.rs
+++ b/src/bin/server.rs
@@ -25,22 +25,31 @@ fn main() {
let mut masses = populate();
- let mut connections = Vec::new();
+ let mut connections : Vec<ServerConnection> = Vec::new();
for stream in listener.incoming() {
match stream {
- Ok(stream) => connections.push(ServerConnection::new(stream, &mut masses)),
+ Ok(stream) => {
+ let new_connection = ServerConnection::new(stream, &mut masses);
+ let exists = connections.iter().position(|connection|
+ connection.name == new_connection.name &&
+ connection.module_type == new_connection.module_type);
+ match exists {
+ Some(index) => { connections.remove(index); },
+ _ => (),
+ }
+ connections.push(new_connection);
+ },
_ => {
for i in 0..connections.len() {
connections[i].process(&mut masses);
}
- connections.retain(|connection| connection.open);
for mass in masses.values_mut() {
mass.process();
}
sleep(Duration::from_millis(100));
- }
+ },
}
}
}