Struct UnifiedDialogManager

Source
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

Source

pub async fn new( transaction_manager: Arc<TransactionManager>, config: DialogManagerConfig, ) -> DialogResult<Self>

Create a new unified dialog manager

§Arguments
  • transaction_manager - Pre-configured transaction manager
  • config - Configuration determining the behavior mode
§Returns

New UnifiedDialogManager instance

Source

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 manager
  • transaction_events - Global transaction event receiver
  • config - Configuration determining the behavior mode
§Returns

New UnifiedDialogManager instance with proper event consumption

Source

pub fn config(&self) -> &DialogManagerConfig

Get the current configuration

Source

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.

Source

pub async fn start(&self) -> DialogResult<()>

Start the unified dialog manager

Initializes the manager for processing based on its configuration mode.

Source

pub async fn stop(&self) -> DialogResult<()>

Stop the unified dialog manager

Gracefully shuts down the manager and all active dialogs.

Source

pub async fn set_session_coordinator( &self, sender: Sender<SessionCoordinationEvent>, ) -> ApiResult<()>

Set session coordinator

Establishes communication with session-core for session management.

Source

pub async fn set_dialog_event_sender( &self, sender: Sender<DialogEvent>, ) -> ApiResult<()>

Set dialog event sender

Establishes dialog event communication for external consumers.

Source

pub fn subscribe_to_dialog_events(&self) -> Receiver<DialogEvent>

Subscribe to dialog events

Returns a receiver for monitoring dialog state changes.

Source

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 call
  • to_uri - Remote URI to call
  • sdp_offer - Optional SDP offer for media negotiation
§Returns

CallHandle for managing the call

Source

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 URI
  • to_uri - Remote URI
§Returns

DialogHandle for the new dialog

Source

pub async fn handle_invite( &self, request: Request, source: SocketAddr, ) -> ApiResult<CallHandle>

Handle incoming INVITE request (Server/Hybrid modes only)

Processes an incoming INVITE to potentially establish a call. Only available in Server and Hybrid modes.

§Arguments
  • request - The INVITE request
  • source - Source address of the request
§Returns

CallHandle for managing the incoming call

Source

pub async fn send_request_in_dialog( &self, dialog_id: &DialogId, method: Method, body: Option<Bytes>, ) -> ApiResult<TransactionKey>

Send a request within an existing dialog

Available in all modes for sending in-dialog requests.

§Arguments
  • dialog_id - The dialog to send the request in
  • method - SIP method to send
  • body - Optional request body
§Returns

Transaction key for tracking the request

Source

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 to
  • response - The response to send
Source

pub async fn build_response( &self, transaction_id: &TransactionKey, status_code: StatusCode, body: Option<String>, ) -> ApiResult<Response>

Build a response for a transaction

Constructs a properly formatted SIP response.

§Arguments
  • transaction_id - Transaction to respond to
  • status_code - HTTP-style status code
  • body - Optional response body (SDP, error details, etc.)
§Returns

Constructed response ready to send

Source

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 to
  • status_code - Status code to send
  • reason - Optional reason phrase
Source

pub async fn send_bye(&self, dialog_id: &DialogId) -> ApiResult<TransactionKey>

Send BYE request to terminate a dialog

Source

pub async fn send_refer( &self, dialog_id: &DialogId, target_uri: String, refer_body: Option<String>, ) -> ApiResult<TransactionKey>

Send REFER request for call transfer

Source

pub async fn send_notify( &self, dialog_id: &DialogId, event: String, body: Option<String>, ) -> ApiResult<TransactionKey>

Send NOTIFY request for event notifications

Source

pub async fn send_update( &self, dialog_id: &DialogId, sdp: Option<String>, ) -> ApiResult<TransactionKey>

Send UPDATE request for media modifications

Source

pub async fn send_info( &self, dialog_id: &DialogId, info_body: String, ) -> ApiResult<TransactionKey>

Send INFO request for application-specific information

Source

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
Source

pub async fn get_dialog_info(&self, dialog_id: &DialogId) -> ApiResult<Dialog>

Get information about a dialog

Source

pub async fn get_dialog_state( &self, dialog_id: &DialogId, ) -> ApiResult<DialogState>

Get the current state of a dialog

Source

pub async fn terminate_dialog(&self, dialog_id: &DialogId) -> ApiResult<()>

Terminate a dialog

Source

pub async fn list_active_dialogs(&self) -> Vec<DialogId>

List all active dialogs

Source

pub async fn get_stats(&self) -> ManagerStats

Get statistics for this manager

Source

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 call
  • original_invite_tx_id - Transaction ID of the original INVITE
  • response - The 200 OK response to acknowledge
§Returns

Success or error

Trait Implementations§

Source§

impl Clone for UnifiedDialogManager

Source§

fn clone(&self) -> UnifiedDialogManager

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UnifiedDialogManager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,