From c8742b1f1498ffe6f618451ada3da3b3ecf2509f Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Fri, 22 May 2020 19:21:11 +0200 Subject: Connecting elements --- src/diplonat.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/diplonat.rs') diff --git a/src/diplonat.rs b/src/diplonat.rs index a4cb787..565c567 100644 --- a/src/diplonat.rs +++ b/src/diplonat.rs @@ -1,28 +1,34 @@ use anyhow::Result; -use futures::future::try_join_all; use log::*; +use tokio::try_join; use crate::consul_actor::ConsulActor; +use crate::igd_actor::IgdActor; use crate::environment::Environment; pub struct Diplonat { - consul: ConsulActor + consul: ConsulActor, + igd: IgdActor } impl Diplonat { pub async fn new() -> Result { let env = Environment::new()?; + let ca = ConsulActor::new(&env.consul_url, &env.consul_node_name); + let ia = IgdActor::new(&ca.rx_open_ports).await?; let ctx = Self { - consul: ConsulActor::new(&env.consul_url, &env.consul_node_name) + consul: ca, + igd: ia }; return Ok(ctx); } pub async fn listen(&mut self) -> Result<()> { - try_join_all(vec![ - self.consul.listen() - ]).await?; + try_join!( + self.consul.listen(), + self.igd.listen() + )?; return Ok(()); } -- cgit v1.2.3