Skip to content

Commit

Permalink
change ConnectionClosedEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
sdwoodbury committed Nov 8, 2023
1 parent 0865bb6 commit 6377a4b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
14 changes: 10 additions & 4 deletions extensions/warp-blink-wrtc/src/blink_impl/blink_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ async fn run(
log::debug!("received webrtc signal for non-active call");
continue;
}
_ if !call_data_map.participant_in_call(call_id, &sender) => {
_ if !call_data_map.contains_participant(call_id, &sender) => {
log::debug!("received signal from someone who isn't part of the call");
continue;
}
Expand All @@ -626,7 +626,7 @@ async fn run(
},
},
GossipSubSignal::Call { sender, call_id, signal } => match signal {
_ if !call_data_map.participant_in_call(call_id, &sender) => {
_ if !call_data_map.contains_participant(call_id, &sender) => {
log::debug!("received signal from someone who isn't part of the call");
continue;
}
Expand Down Expand Up @@ -754,14 +754,16 @@ async fn run(
}
},
simple_webrtc::events::EmittedEvents::Disconnected { peer }
| simple_webrtc::events::EmittedEvents::ConnectionFailed { peer }
| simple_webrtc::events::EmittedEvents::ConnectionClosed { peer }=> {
| simple_webrtc::events::EmittedEvents::ConnectionFailed { peer } => {
// todo: dont' call this multiple times per peer
let ac = active_call.unwrap_or_default();
call_data_map.remove_participant(ac, &peer);

if let Err(e) = host_media::remove_sink_track(peer.clone()).await {
log::error!("failed to send media_track command: {e}");
}

// possibly redundant
webrtc_controller.hang_up(&peer).await;

if let Some(data) = call_data_map.map.get(&ac) {
Expand All @@ -777,6 +779,10 @@ async fn run(
}
}
},
simple_webrtc::events::EmittedEvents::ConnectionClosed { peer } => {
// hoping this will trigger the Disconnected event.
webrtc_controller.hang_up(&peer).await;
}
simple_webrtc::events::EmittedEvents::Sdp { dest, sdp } => {
let topic = ipfs_routes::peer_signal_route(&dest, &active_call.unwrap_or_default());
let signal = PeerSignal::Sdp(*sdp);
Expand Down
7 changes: 0 additions & 7 deletions extensions/warp-blink-wrtc/src/blink_impl/data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,6 @@ impl CallDataMap {
}
}

pub fn participant_in_call(&self, call_id: Uuid, peer_id: &DID) -> bool {
self.map
.get(&call_id)
.map(|x| x.info.contains_participant(peer_id))
.unwrap_or_default()
}

pub fn remove_call(&mut self, call_id: Uuid) {
self.map.remove(&call_id);
}
Expand Down

0 comments on commit 6377a4b

Please sign in to comment.