mirror of
https://github.com/Astatin3/unshell.git
synced 2026-06-08 22:38:01 -06:00
Fix examples for renamed leaf endpoint surface
Update the remote shell examples to use unshell::leaves and the leaf_endpoint feature-gated endpoint module, and restore the local macro aliasing needed after removing the direct unshell dependency from unshell-leaves.
This commit is contained in:
@@ -9,29 +9,32 @@ use std::net::TcpStream;
|
||||
use std::sync::mpsc::RecvTimeoutError;
|
||||
use std::time::Duration;
|
||||
|
||||
use unshell::leaves::remote_shell;
|
||||
use unshell::protocol::tree::Ingress;
|
||||
use unshell_leaves::remote_shell;
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let mut stream = TcpStream::connect(remote_shell::LISTEN_ADDR)?;
|
||||
let frame_rx = remote_shell::spawn_frame_reader(stream.try_clone()?);
|
||||
let mut runtime = remote_shell::build_agent_runtime();
|
||||
let mut stream = TcpStream::connect(remote_shell::endpoint::LISTEN_ADDR)?;
|
||||
let frame_rx = remote_shell::endpoint::spawn_frame_reader(stream.try_clone()?);
|
||||
let mut runtime = remote_shell::endpoint::build_agent_runtime();
|
||||
|
||||
println!("connected to controller at {}", remote_shell::LISTEN_ADDR);
|
||||
println!(
|
||||
"connected to controller at {}",
|
||||
remote_shell::endpoint::LISTEN_ADDR
|
||||
);
|
||||
|
||||
loop {
|
||||
match frame_rx.recv_timeout(Duration::from_millis(25)) {
|
||||
Ok(result) => {
|
||||
let frame = result?;
|
||||
let outcome = runtime.receive(&Ingress::Parent, frame)?;
|
||||
remote_shell::write_frames(&mut stream, &outcome.frames)?;
|
||||
remote_shell::endpoint::write_frames(&mut stream, &outcome.frames)?;
|
||||
}
|
||||
Err(RecvTimeoutError::Timeout) => {}
|
||||
Err(RecvTimeoutError::Disconnected) => break,
|
||||
}
|
||||
|
||||
let outcome = runtime.poll()?;
|
||||
remote_shell::write_frames(&mut stream, &outcome.frames)?;
|
||||
remote_shell::endpoint::write_frames(&mut stream, &outcome.frames)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user