summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authortom barrett <spalf0@gmail.com>2018-03-19 05:06:50 -0500
committertom barrett <spalf0@gmail.com>2018-03-19 05:06:50 -0500
commitc297e871b7ce8935dd3bb1c65ecae37000d9a331 (patch)
treed6371df117020da5381acec1024c4fcb35060c76 /src/bin
parent7a4403d2a26250c82b6f089de3b56e076c69e39a (diff)
-pass module information in a serializable way
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/client.rs13
-rw-r--r--src/bin/server.rs6
2 files changed, 12 insertions, 7 deletions
diff --git a/src/bin/client.rs b/src/bin/client.rs
index 558f914..cf12e53 100644
--- a/src/bin/client.rs
+++ b/src/bin/client.rs
@@ -3,11 +3,13 @@ use std::io::prelude::*;
use std::io::BufReader;
use std::net::TcpStream;
+extern crate serde_json;
+
extern crate space;
use space::dashboard::client_dashboard;
use space::engines::client_engines;
use space::navigation::client_navigation;
-use space::module::{Module, from_primitive};
+use space::module::Module;
fn main() {
let mut name = String::new();
@@ -28,7 +30,8 @@ fn main() {
let mut data = String::new();
buff_r.read_line(&mut data).unwrap();
- let modules : Vec<&str> = data.split(",").collect();
+ let mut modules : Vec<&str> = data.split(";").collect();
+ modules.pop();
println!("Choose your module:");
for (i, module) in modules.iter().enumerate() {
@@ -37,9 +40,11 @@ fn main() {
let mut choice = String::new();
io::stdin().read_line(&mut choice).expect("Failed");
- stream.write(choice.as_bytes()).unwrap();
+ let mut module = modules[choice.replace("\n","").parse::<usize>().unwrap()].to_owned();
+ module.push_str("\n");
+ stream.write(module.as_bytes()).unwrap();
- let module = from_primitive(choice);
+ let module : Module = serde_json::from_str(&module.replace("\n","")).unwrap();
match module {
Module::Dashboard => client_dashboard(buff_r),
Module::Engines => client_engines(stream, buff_r),
diff --git a/src/bin/server.rs b/src/bin/server.rs
index 36840c1..16186d7 100644
--- a/src/bin/server.rs
+++ b/src/bin/server.rs
@@ -11,9 +11,9 @@ use space::connection::Connection;
fn populate() -> Vec<Box<Mass>> {
let mut masses : Vec<Box<Mass>> = Vec::new();
- masses.push(Box::new(Astroid::new()));
- masses.push(Box::new(Astroid::new()));
- masses.push(Box::new(Astroid::new()));
+ for _ in 0..10 {
+ masses.push(Box::new(Astroid::new()));
+ }
masses
}