use std::net::SocketAddr;
use hydroflow::hydroflow_syntax;
use hydroflow::util::{UdpSink, UdpStream};
use crate::helpers::parse_command;
use crate::protocol::KvsResponse;
use crate::Opts;
pub(crate) async fn run_client(
outbound: UdpSink,
inbound: UdpStream,
server_addr: SocketAddr,
opts: Opts,
) {
println!("Client live!");
let mut hf = hydroflow_syntax! {
outbound_chan = dest_sink_serde(outbound);
inbound_chan = source_stream_serde(inbound) -> map(Result::unwrap);
source_stdin()
-> filter_map(|line| parse_command(line.unwrap()))
-> map(|msg| { (msg, server_addr) })
-> outbound_chan;
inbound_chan -> for_each(|(response, _addr): (KvsResponse, _)| println!("Got a Response: {:?}", response));
};
#[cfg(feature = "debugging")]
if let Some(graph) = opts.graph {
let serde_graph = hf
.meta_graph()
.expect("No graph found, maybe failed to parse.");
serde_graph.open_graph(graph, opts.write_config).unwrap();
}
let _ = opts;
hf.run_async().await.unwrap();
}