use networking::{ArtificeConfig, ArtificeHost, ArtificePeer};
use std::fs::File;
use std::io::Read;
fn main() {
let mut config_file = File::open("host.json").unwrap();
let mut conf_vec = String::new();
config_file.read_to_string(&mut conf_vec).unwrap();
let config: ArtificeConfig = serde_json::from_str(&conf_vec).unwrap();
let mut file = File::open("peer.json").unwrap();
let mut invec = Vec::new();
file.read_to_end(&mut invec).unwrap();
let string = String::from_utf8(invec).unwrap();
let peer: ArtificePeer = serde_json::from_str(&string).unwrap();
let host = ArtificeHost::client_only(&config);
let mut stream = host.connect(peer).unwrap();
let mut buffer = Vec::new();
println!("about to read from sream");
println!(
"got {} bytes from server",
stream.recv(&mut buffer).unwrap()
);
println!("read from stream");
let string = String::from_utf8(buffer).unwrap();
println!("got message: {} from server", string);
}