use igd::aio::*; use log::*; use anyhow::{Result, Context}; use tokio::sync::watch; use crate::messages; pub struct IgdActor { rx_ports: watch::Receiver, gateway: Gateway, } impl IgdActor { pub async fn new(rxp: &watch::Receiver) -> Result { let gw = search_gateway(Default::default()) .await .context("Failed to find gateway")?; info!("Gateway: {}", gw); let ctx = Self { gateway: gw, rx_ports: rxp.clone() }; return Ok(ctx); } pub async fn listen(&mut self) -> Result<()> { while let Some(ports) = self.rx_ports.recv().await { println!("received = {:#?}", ports); } return Ok(()); } }