use std::path::Path;
use crate::state::{Link, Said};
pub fn tick(link: &Link, root: &Path) {
let standing = link.standing();
let (Some((channel, aim)), Some(conversation)) = (standing.aimed(), standing.conversation)
else {
return;
};
let envelope = crate::verbs::follow(aim.address.clone(), conversation.clone());
let held = crate::seat::route(root, &envelope).and_then(|(open, carried)| {
open.follow(&carried, &mut |frame| {
link.live(&channel, &conversation, frame);
!link.stopped() && still_on(link, &aim, &conversation)
})
});
if let Err(why) = held {
link.heard(&channel, Said::Unreachable(why));
}
}
fn still_on(link: &Link, aim: &crate::ui::Aim, conversation: &str) -> bool {
let standing = link.standing();
standing.aim.as_ref() == Some(aim) && standing.conversation.as_deref() == Some(conversation)
}
#[cfg(test)]
mod tests;