Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/dialog/dialog_layer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use super::authenticate::Credential;
use super::dialog::DialogStateSender;
use super::{dialog::Dialog, server_dialog::ServerInviteDialog, DialogId};
use crate::dialog::client_dialog::ClientInviteDialog;
use crate::dialog::dialog::{DialogInner, DialogStateReceiver};
use crate::transaction::key::TransactionRole;
use crate::transaction::make_tag;
Expand Down Expand Up @@ -238,6 +239,33 @@ impl DialogLayer {
Err(_) => None,
}
}
/// Returns all client-side INVITE dialogs (UAC) that share the given Call-ID.
///
/// In a forking scenario, multiple client dialogs can exist for the same
/// Call-ID (same local From-tag, different remote To-tags). This helper
/// scans the internal dialog registry and returns all `ClientInviteDialog`
/// instances whose `DialogId.call_id` equals the provided `call_id`.
///
/// The returned vector may be empty if no matching client dialogs are found.
pub fn get_client_dialog_by_call_id(&self, call_id: &str) -> Vec<ClientInviteDialog> {
let dialogs = match self.inner.dialogs.read() {
Ok(guard) => guard,
Err(_) => {
// If the lock is poisoned, we conservatively return an empty list.
return Vec::new();
}
};

dialogs
.values()
.filter_map(|dlg| match dlg {
Dialog::ClientInvite(client_dlg) if client_dlg.id().call_id == call_id => {
Some(client_dlg.clone())
}
_ => None,
})
.collect()
}

pub fn remove_dialog(&self, id: &DialogId) {
info!(%id, "remove dialog");
Expand Down