From 6fb0b0d918963a22aeb4050139e8d0000c74a9ff Mon Sep 17 00:00:00 2001 From: tom barrett Date: Thu, 21 Mar 2019 09:48:59 -0500 Subject: simplified client sending and added more tractorbeam options --- src/client/tractorbeam.rs | 48 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 15 deletions(-) (limited to 'src/client/tractorbeam.rs') diff --git a/src/client/tractorbeam.rs b/src/client/tractorbeam.rs index c8a6d92..0274886 100644 --- a/src/client/tractorbeam.rs +++ b/src/client/tractorbeam.rs @@ -6,13 +6,19 @@ use self::termion::raw::IntoRawMode; use std::io::{stdout, Read, Write}; use std::io::{BufRead, BufReader}; use std::net::TcpStream; +use std::str::FromStr; use crate::modules::tractorbeam; pub fn client_tractorbeam(mut stream: TcpStream, mut buff_r: BufReader) { let stdout = stdout(); let mut stdout = stdout.lock().into_raw_mode().unwrap(); - let mut stdin = async_stdin().bytes(); + let mut async_in = async_stdin(); + + let mut server_recv_data = tractorbeam::ServerRecvData { + key: String::from_str("").unwrap(), + desired_distance: None, + }; loop { let mut recv = String::new(); @@ -22,30 +28,36 @@ pub fn client_tractorbeam(mut stream: TcpStream, mut buff_r: BufReader write!( stdout, - "{}Press o to pull, p to push, b to bring to 5m.", + "{}Press o to pull, p to push, b to bring to a specific distance, a to acquire item.", clear ) .unwrap(), tractorbeam::Status::Push => write!( stdout, - "{}Press o to pull, p to stop pushing, b to bring to 5m.", + "{}Press o to pull, p to stop pushing, b to bring to a specific distance, a to acquire item.", clear ) .unwrap(), tractorbeam::Status::Pull => write!( stdout, - "{}Press o to stop pulling, p to push, b to bring to 5m.", + "{}Press o to stop pulling, p to push, b to bring to a specific distance, a to acquire item.", clear ) .unwrap(), tractorbeam::Status::Bring => write!( stdout, - "{}Press o to pulling, p to push, b to stop bringing to 5m.", + "{}Press o to pull, p to push, b to stop bringing to {} m, a to acquire item.", + clear, + data.desired_distance.unwrap(), + ) + .unwrap(), + tractorbeam::Status::Acquire => write!( + stdout, + "{}Press o to pull, p to push, b to bring to a specific distance, a to stop acquiring the item.", clear ) .unwrap(), @@ -54,16 +66,22 @@ pub fn client_tractorbeam(mut stream: TcpStream, mut buff_r: BufReader