From 366d9ee25c2b341cd7f4c0431c7e97d892625d0b Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 12 Mar 2022 08:02:58 +0100 Subject: [PATCH] Fix propagation issue --- Cargo.lock | 1 + Cargo.toml | 3 ++- src/controllers/rtc_relay_controller.rs | 10 ++++++---- src/controllers/user_ws_controller.rs | 7 +++---- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b14d04f..86b15d3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -735,6 +735,7 @@ dependencies = [ "serde", "serde_json", "sha1", + "tokio", "url", "webauthn-rs", "webpage", diff --git a/Cargo.toml b/Cargo.toml index f8994e1..1554f02 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,4 +42,5 @@ webpage = "1.2.0" gouth = "0.2.0" webauthn-rs = "0.3.2" url = "2.2.2" -async-recursion = "1.0.0" \ No newline at end of file +async-recursion = "1.0.0" +tokio = "1.17.0" \ No newline at end of file diff --git a/src/controllers/rtc_relay_controller.rs b/src/controllers/rtc_relay_controller.rs index 50e824a..fbb4b38 100644 --- a/src/controllers/rtc_relay_controller.rs +++ b/src/controllers/rtc_relay_controller.rs @@ -99,18 +99,20 @@ impl actix::Actor for RtcRelayActor { }).unwrap()) } - fn stopped(&mut self, ctx: &mut Self::Context) { + fn stopping(&mut self, _: &mut Self::Context) -> Running { println!("Closed connection to RTC relay."); let future = async move { // Propagate information if let Err(e) = events_helper::propagate_event(Event::ClosedRTCRelayWebSocket).await { eprintln!("Failed to propagate rtc closed event! {:#?}", e); + } else { + eprintln!("Successfully propagated RTC relay stopped event!"); } - - eprintln!("Successfully propagated RTC relay stopped envent!"); }; - future.into_actor(self).wait(ctx); + futures::executor::block_on(future); + + Running::Stop } } diff --git a/src/controllers/user_ws_controller.rs b/src/controllers/user_ws_controller.rs index cb9142f..e4bfa6a 100644 --- a/src/controllers/user_ws_controller.rs +++ b/src/controllers/user_ws_controller.rs @@ -320,13 +320,12 @@ impl Actor for WsSession { let future = async move { if let Err(e) = events_helper::propagate_event(Event::UserWsClosed(conn)).await { eprintln!("Failed to propagate web socket closed event ! {:#?}", e); + } else { + eprintln!("Successfully propagated user ws stopping event!"); } - - // TODO : remove - eprintln!("Successfully propagated user ws stopping event!"); }; - future.into_actor(self).wait(ctx); + futures::executor::block_on(future); } remove_connection(ctx.address());