diff --git a/src/.api.rs.swp b/src/.api.rs.swp index 4314426..e6b20c3 100644 Binary files a/src/.api.rs.swp and b/src/.api.rs.swp differ diff --git a/src/.parsing.rs.swp b/src/.parsing.rs.swp index 3b978e8..b0a3923 100644 Binary files a/src/.parsing.rs.swp and b/src/.parsing.rs.swp differ diff --git a/src/api.rs b/src/api.rs index a506f0f..7efc52f 100644 --- a/src/api.rs +++ b/src/api.rs @@ -72,9 +72,11 @@ pub async fn api_process .map(|index: usize, tx_handle: Sender<(bool,usize)>| { debug!("Choice: {}", index); let _ = tx_handle.send((true,index)); + let reply = "ack"; + warp::reply::json(&reply) }).boxed(); - let routes = main.or(characters); + let routes = main.or(characters).or(choice); // Start the server warp::serve(routes) .run(([127, 0, 0, 1],config::API_PORT)) diff --git a/src/parsing.rs b/src/parsing.rs index aad0b35..afc7ef1 100644 --- a/src/parsing.rs +++ b/src/parsing.rs @@ -62,11 +62,16 @@ pub async fn token_parse( }, "choice" => { - index += match choice_parse(index+1, &tokens, &data_to_send).await + let (_,jump_points) = match choice_parse(index+1, &tokens, &data_to_send).await { - Ok(increment) => increment, + Ok((increment,jump_point)) => (increment,jump_point), Err(error) => return Err(error), - } + }; + if rx.recv().is_err() { warn!("Error sending choices to client"); }; + let (_, choice) = rx.recv().unwrap(); // TODO eh + index = jump_points[choice]; + debug!("{:?} {} {}",jump_points, choice, index); + continue } _ => {