pub struct UnifiedDialogManager { /* private fields */ }
Expand description
Unified DialogManager that supports client, server, and hybrid modes
This is the core implementation that replaces separate DialogClient and DialogServer types with a single, configuration-driven approach. The behavior is determined by the DialogManagerConfig provided during construction.
§Capabilities by Mode
§Client Mode
- Make outgoing calls (
make_call
) - Handle authentication challenges
- Send in-dialog requests
- Build and send responses (when needed)
§Server Mode
- Handle incoming calls (via session coordination)
- Auto-respond to OPTIONS/REGISTER (if configured)
- Build and send responses
- Send in-dialog requests
§Hybrid Mode
- All client capabilities
- All server capabilities
- Full bidirectional SIP support
§Thread Safety
UnifiedDialogManager is fully thread-safe and can be shared across async tasks
using Arc
Implementations§
Source§impl UnifiedDialogManager
impl UnifiedDialogManager
Sourcepub async fn new(
transaction_manager: Arc<TransactionManager>,
config: DialogManagerConfig,
) -> DialogResult<Self>
pub async fn new( transaction_manager: Arc<TransactionManager>, config: DialogManagerConfig, ) -> DialogResult<Self>
Sourcepub async fn with_global_events(
transaction_manager: Arc<TransactionManager>,
transaction_events: Receiver<TransactionEvent>,
config: DialogManagerConfig,
) -> DialogResult<Self>
pub async fn with_global_events( transaction_manager: Arc<TransactionManager>, transaction_events: Receiver<TransactionEvent>, config: DialogManagerConfig, ) -> DialogResult<Self>
Create a new unified dialog manager with global events (RECOMMENDED)
§Arguments
transaction_manager
- Pre-configured transaction managertransaction_events
- Global transaction event receiverconfig
- Configuration determining the behavior mode
§Returns
New UnifiedDialogManager instance with proper event consumption
Sourcepub fn config(&self) -> &DialogManagerConfig
pub fn config(&self) -> &DialogManagerConfig
Get the current configuration
Sourcepub fn core(&self) -> &DialogManager
pub fn core(&self) -> &DialogManager
Get the underlying core dialog manager
Provides access to the core dialog management functionality. Useful for advanced operations that bypass the unified API.
Sourcepub async fn start(&self) -> DialogResult<()>
pub async fn start(&self) -> DialogResult<()>
Start the unified dialog manager
Initializes the manager for processing based on its configuration mode.
Sourcepub async fn stop(&self) -> DialogResult<()>
pub async fn stop(&self) -> DialogResult<()>
Stop the unified dialog manager
Gracefully shuts down the manager and all active dialogs.
Sourcepub async fn set_session_coordinator(
&self,
sender: Sender<SessionCoordinationEvent>,
) -> ApiResult<()>
pub async fn set_session_coordinator( &self, sender: Sender<SessionCoordinationEvent>, ) -> ApiResult<()>
Set session coordinator
Establishes communication with session-core for session management.
Sourcepub async fn set_dialog_event_sender(
&self,
sender: Sender<DialogEvent>,
) -> ApiResult<()>
pub async fn set_dialog_event_sender( &self, sender: Sender<DialogEvent>, ) -> ApiResult<()>
Set dialog event sender
Establishes dialog event communication for external consumers.
Sourcepub fn subscribe_to_dialog_events(&self) -> Receiver<DialogEvent>
pub fn subscribe_to_dialog_events(&self) -> Receiver<DialogEvent>
Subscribe to dialog events
Returns a receiver for monitoring dialog state changes.
Sourcepub async fn make_call(
&self,
from_uri: &str,
to_uri: &str,
sdp_offer: Option<String>,
) -> ApiResult<CallHandle>
pub async fn make_call( &self, from_uri: &str, to_uri: &str, sdp_offer: Option<String>, ) -> ApiResult<CallHandle>
Make an outgoing call (Client/Hybrid modes only)
Creates a new dialog and sends an INVITE request to establish a call. Only available in Client and Hybrid modes.
§Arguments
from_uri
- Local URI for the callto_uri
- Remote URI to callsdp_offer
- Optional SDP offer for media negotiation
§Returns
CallHandle for managing the call
Sourcepub async fn create_dialog(
&self,
from_uri: &str,
to_uri: &str,
) -> ApiResult<DialogHandle>
pub async fn create_dialog( &self, from_uri: &str, to_uri: &str, ) -> ApiResult<DialogHandle>
Create an outgoing dialog without sending INVITE (Client/Hybrid modes only)
Creates a dialog in preparation for sending requests. Useful for scenarios where you want to create the dialog before sending the INVITE.
§Arguments
from_uri
- Local URIto_uri
- Remote URI
§Returns
DialogHandle for the new dialog
Sourcepub async fn handle_invite(
&self,
request: Request,
source: SocketAddr,
) -> ApiResult<CallHandle>
pub async fn handle_invite( &self, request: Request, source: SocketAddr, ) -> ApiResult<CallHandle>
Sourcepub async fn send_request_in_dialog(
&self,
dialog_id: &DialogId,
method: Method,
body: Option<Bytes>,
) -> ApiResult<TransactionKey>
pub async fn send_request_in_dialog( &self, dialog_id: &DialogId, method: Method, body: Option<Bytes>, ) -> ApiResult<TransactionKey>
Sourcepub async fn send_response(
&self,
transaction_id: &TransactionKey,
response: Response,
) -> ApiResult<()>
pub async fn send_response( &self, transaction_id: &TransactionKey, response: Response, ) -> ApiResult<()>
Send a response to a transaction
Available in all modes for sending responses to received requests.
§Arguments
transaction_id
- Transaction to respond toresponse
- The response to send
Sourcepub async fn build_response(
&self,
transaction_id: &TransactionKey,
status_code: StatusCode,
body: Option<String>,
) -> ApiResult<Response>
pub async fn build_response( &self, transaction_id: &TransactionKey, status_code: StatusCode, body: Option<String>, ) -> ApiResult<Response>
Sourcepub async fn send_status_response(
&self,
transaction_id: &TransactionKey,
status_code: StatusCode,
_reason: Option<String>,
) -> ApiResult<()>
pub async fn send_status_response( &self, transaction_id: &TransactionKey, status_code: StatusCode, _reason: Option<String>, ) -> ApiResult<()>
Send a status response (convenience method)
Builds and sends a simple status response.
§Arguments
transaction_id
- Transaction to respond tostatus_code
- Status code to sendreason
- Optional reason phrase
Sourcepub async fn send_bye(&self, dialog_id: &DialogId) -> ApiResult<TransactionKey>
pub async fn send_bye(&self, dialog_id: &DialogId) -> ApiResult<TransactionKey>
Send BYE request to terminate a dialog
Sourcepub async fn send_refer(
&self,
dialog_id: &DialogId,
target_uri: String,
refer_body: Option<String>,
) -> ApiResult<TransactionKey>
pub async fn send_refer( &self, dialog_id: &DialogId, target_uri: String, refer_body: Option<String>, ) -> ApiResult<TransactionKey>
Send REFER request for call transfer
Sourcepub async fn send_notify(
&self,
dialog_id: &DialogId,
event: String,
body: Option<String>,
) -> ApiResult<TransactionKey>
pub async fn send_notify( &self, dialog_id: &DialogId, event: String, body: Option<String>, ) -> ApiResult<TransactionKey>
Send NOTIFY request for event notifications
Sourcepub async fn send_update(
&self,
dialog_id: &DialogId,
sdp: Option<String>,
) -> ApiResult<TransactionKey>
pub async fn send_update( &self, dialog_id: &DialogId, sdp: Option<String>, ) -> ApiResult<TransactionKey>
Send UPDATE request for media modifications
Sourcepub async fn send_info(
&self,
dialog_id: &DialogId,
info_body: String,
) -> ApiResult<TransactionKey>
pub async fn send_info( &self, dialog_id: &DialogId, info_body: String, ) -> ApiResult<TransactionKey>
Send INFO request for application-specific information
Sourcepub async fn send_cancel(
&self,
dialog_id: &DialogId,
) -> ApiResult<TransactionKey>
pub async fn send_cancel( &self, dialog_id: &DialogId, ) -> ApiResult<TransactionKey>
Send CANCEL request to cancel a pending INVITE
This method cancels a pending INVITE transaction that hasn’t received a final response. Only works for dialogs in the Early or Initial state (before 200 OK is received).
§Arguments
dialog_id
- The dialog to cancel
§Returns
Transaction key for the CANCEL request
§Errors
Returns an error if:
- Dialog is not found
- Dialog is not in Early or Initial state
- No pending INVITE transaction found
Sourcepub async fn get_dialog_info(&self, dialog_id: &DialogId) -> ApiResult<Dialog>
pub async fn get_dialog_info(&self, dialog_id: &DialogId) -> ApiResult<Dialog>
Get information about a dialog
Sourcepub async fn get_dialog_state(
&self,
dialog_id: &DialogId,
) -> ApiResult<DialogState>
pub async fn get_dialog_state( &self, dialog_id: &DialogId, ) -> ApiResult<DialogState>
Get the current state of a dialog
Sourcepub async fn terminate_dialog(&self, dialog_id: &DialogId) -> ApiResult<()>
pub async fn terminate_dialog(&self, dialog_id: &DialogId) -> ApiResult<()>
Terminate a dialog
Sourcepub async fn list_active_dialogs(&self) -> Vec<DialogId>
pub async fn list_active_dialogs(&self) -> Vec<DialogId>
List all active dialogs
Sourcepub async fn get_stats(&self) -> ManagerStats
pub async fn get_stats(&self) -> ManagerStats
Get statistics for this manager
Sourcepub async fn send_ack_for_2xx_response(
&self,
dialog_id: &DialogId,
original_invite_tx_id: &TransactionKey,
response: &Response,
) -> ApiResult<()>
pub async fn send_ack_for_2xx_response( &self, dialog_id: &DialogId, original_invite_tx_id: &TransactionKey, response: &Response, ) -> ApiResult<()>
Send ACK for 2xx response to INVITE
Handles the automatic ACK sending required by RFC 3261 for 200 OK responses to INVITE. Available in all modes for proper SIP protocol compliance.
§Arguments
dialog_id
- Dialog ID for the calloriginal_invite_tx_id
- Transaction ID of the original INVITEresponse
- The 200 OK response to acknowledge
§Returns
Success or error
Trait Implementations§
Source§impl Clone for UnifiedDialogManager
impl Clone for UnifiedDialogManager
Source§fn clone(&self) -> UnifiedDialogManager
fn clone(&self) -> UnifiedDialogManager
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more