Struct DialogManager

Source
pub struct DialogManager { /* private fields */ }

Implementations§

Source§

impl DialogManager

Source

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

Create a new dialog manager

ARCHITECTURE: dialog-core receives TransactionManager via dependency injection. The application level is responsible for creating the transaction layer.

§Arguments
  • transaction_manager - The transaction manager to use for SIP message reliability
  • local_address - The local address to use in Via headers and Contact headers
§Returns

A new DialogManager instance ready for use

Source

pub async fn with_global_events( transaction_manager: Arc<TransactionManager>, transaction_events: Receiver<TransactionEvent>, local_address: SocketAddr, ) -> DialogResult<Self>

Create a new dialog manager with global transaction events (RECOMMENDED)

This constructor follows the working pattern from transaction-core examples by receiving global transaction events for proper event consumption.

§Arguments
  • transaction_manager - The transaction manager to use for SIP message reliability
  • transaction_events - Global transaction event receiver
  • local_address - The local address to use in Via headers and Contact headers
§Returns

A new DialogManager instance with proper event consumption

Source

pub fn local_address(&self) -> SocketAddr

Get the configured local address

Returns the local address that this DialogManager uses for Via headers and Contact headers when creating SIP requests.

Source

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

Set the session coordinator for sending events to session-core

This establishes the communication channel between dialog-core and session-core, maintaining the proper architectural layer separation.

§Arguments
  • sender - Channel sender for session coordination events
Source

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

Set the dialog event sender for external consumers (session-core)

This establishes the dialog event communication channel that session-core can use to receive high-level dialog state changes and events.

§Arguments
  • sender - Channel sender for dialog events
Source

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

Subscribe to dialog events

Returns a receiver for dialog events that session-core can use to monitor dialog state changes and other dialog-level events.

§Returns

A receiver for dialog events

Source

pub async fn emit_dialog_event(&self, event: DialogEvent)

Emit a dialog event to external consumers

Sends dialog events to session-core for high-level dialog state management. This maintains the proper architectural separation where dialog-core handles SIP protocol details and session-core handles session logic.

Source

pub async fn emit_session_coordination_event( &self, event: SessionCoordinationEvent, )

Emit a session coordination event

Sends session coordination events for legacy compatibility and specific session management operations.

Source

pub async fn handle_message( &self, message: Message, source: SocketAddr, ) -> DialogResult<()>

CENTRAL DISPATCHER: Handle incoming SIP messages

This is the main entry point for processing SIP messages in dialog-core. It routes messages to the appropriate method-specific handlers while maintaining RFC 3261 compliance for dialog state management.

§Arguments
  • message - The SIP message (Request or Response)
  • source - Source address of the message
§Returns

Result indicating success or the specific error encountered

Source

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

Start the dialog manager

Initializes the dialog manager for processing. This can include starting background tasks for dialog cleanup, recovery, and maintenance.

Source

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

Stop the dialog manager

Gracefully shuts down the dialog manager, terminating all active dialogs and cleaning up resources according to RFC 3261 requirements.

Source

pub fn transaction_manager(&self) -> &Arc<TransactionManager>

Get the transaction manager reference

Provides access to the underlying transaction manager for cases where direct transaction operations are needed.

Source

pub fn dialog_count(&self) -> usize

Get dialog count

Returns the current number of active dialogs.

Source

pub fn has_dialog(&self, dialog_id: &DialogId) -> bool

Check if a dialog exists

§Arguments
  • dialog_id - The dialog ID to check
§Returns

true if the dialog exists, false otherwise

Source

pub fn cleanup_transaction_receiver(&self, transaction_id: &TransactionKey)

Clean up completed transaction event receivers

This method removes transaction-to-dialog mappings for completed transactions.

§Arguments
  • transaction_id - The transaction ID to clean up
Source

pub fn find_invite_transaction_for_dialog( &self, dialog_id: &DialogId, ) -> Option<TransactionKey>

Find the INVITE transaction associated with a dialog

This is used for CANCEL operations to find the pending INVITE transaction that needs to be cancelled.

§Arguments
  • dialog_id - The dialog ID to find the INVITE transaction for
§Returns

The transaction key for the INVITE if found, None otherwise

Source

pub fn set_config(&mut self, config: DialogManagerConfig)

Set the unified configuration for this DialogManager

Enables mode-specific behavior based on configuration. This method allows the UnifiedDialogManager to inject configuration.

§Arguments
  • config - Unified configuration determining behavior mode
Source

pub fn config(&self) -> Option<&DialogManagerConfig>

Get the current configuration (if any)

Returns the unified configuration if it was provided.

Source

pub fn should_auto_respond_to_options(&self) -> bool

Check if auto-response to OPTIONS requests is enabled

Returns true if the unified configuration enables automatic OPTIONS responses. If no configuration is set, defaults to false (session layer handling).

Source

pub fn should_auto_respond_to_register(&self) -> bool

Check if auto-response to REGISTER requests is enabled

Returns true if the unified configuration enables automatic REGISTER responses. If no configuration is set, defaults to false (session layer handling).

Source

pub fn supports_outgoing_calls(&self) -> bool

Check if outgoing calls are supported

Returns true if the configuration supports outgoing calls (Client/Hybrid modes). If no configuration is set, defaults to true for backward compatibility.

Source

pub fn supports_incoming_calls(&self) -> bool

Check if incoming calls are supported

Returns true if the configuration supports incoming calls (Server/Hybrid modes). If no configuration is set, defaults to true for backward compatibility.

Source§

impl DialogManager

Source

pub async fn create_dialog(&self, request: &Request) -> DialogResult<DialogId>

Source

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

Source

pub fn get_dialog(&self, dialog_id: &DialogId) -> DialogResult<Dialog>

Source

pub fn get_dialog_mut( &self, dialog_id: &DialogId, ) -> DialogResult<RefMut<'_, DialogId, Dialog>>

Source

pub async fn store_dialog(&self, dialog: Dialog) -> DialogResult<()>

Source

pub fn list_dialogs(&self) -> Vec<DialogId>

Source

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

Source

pub async fn update_dialog_state( &self, dialog_id: &DialogId, new_state: DialogState, ) -> DialogResult<()>

Source

pub async fn create_outgoing_dialog( &self, local_uri: Uri, remote_uri: Uri, call_id: Option<String>, ) -> DialogResult<DialogId>

Source

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

Source

pub async fn handle_bye(&self, request: Request) -> DialogResult<()>

Source

pub async fn handle_cancel(&self, request: Request) -> DialogResult<()>

Source

pub async fn handle_ack(&self, request: Request) -> DialogResult<()>

Source

pub async fn handle_options( &self, request: Request, source: SocketAddr, ) -> DialogResult<()>

Source

pub async fn handle_register( &self, request: Request, source: SocketAddr, ) -> DialogResult<()>

Source

pub async fn handle_update(&self, request: Request) -> DialogResult<()>

Source

pub async fn handle_info( &self, request: Request, source: SocketAddr, ) -> DialogResult<()>

Source

pub async fn handle_refer( &self, request: Request, source: SocketAddr, ) -> DialogResult<()>

Source

pub async fn handle_subscribe( &self, request: Request, source: SocketAddr, ) -> DialogResult<()>

Source

pub async fn handle_notify( &self, request: Request, source: SocketAddr, ) -> DialogResult<()>

Source

pub async fn handle_response( &self, response: Response, transaction_id: TransactionKey, ) -> DialogResult<()>

Source

pub async fn find_dialog_for_request( &self, request: &Request, ) -> Option<DialogId>

Source

pub fn find_dialog_for_transaction( &self, transaction_id: &TransactionKey, ) -> DialogResult<DialogId>

Source

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

Source

pub async fn send_response( &self, transaction_id: &TransactionKey, response: Response, ) -> DialogResult<()>

Source

pub fn associate_transaction_with_dialog( &self, transaction_id: &TransactionKey, dialog_id: &DialogId, )

Source

pub async fn send_ack_for_2xx_response( &self, dialog_id: &DialogId, original_invite_tx_id: &TransactionKey, response: &Response, ) -> DialogResult<()>

Source

pub async fn create_ack_for_2xx_response( &self, original_invite_tx_id: &TransactionKey, response: &Response, ) -> DialogResult<Request>

Source

pub async fn find_transaction_by_message( &self, message: &Message, ) -> DialogResult<Option<TransactionKey>>

Source§

impl DialogManager

Source

pub async fn process_transaction_event( &self, transaction_id: &TransactionKey, dialog_id: &DialogId, event: TransactionEvent, ) -> DialogResult<()>

Process a transaction event and update dialog state accordingly

This is the core event-driven state management for dialogs based on transaction layer events. It implements proper RFC 3261 dialog state transitions.

Source§

impl DialogManager

Source

pub async fn create_server_transaction_for_request( &self, request: Request, source: SocketAddr, ) -> DialogResult<TransactionKey>

Create server transaction for incoming request

Helper to create server transactions with proper error handling.

Source

pub async fn create_client_transaction_for_request( &self, request: Request, destination: SocketAddr, method: &Method, ) -> DialogResult<TransactionKey>

Create client transaction for outgoing request

Helper to create client transactions with method-specific handling.

Source

pub async fn cancel_invite_transaction_with_dialog( &self, invite_tx_id: &TransactionKey, ) -> DialogResult<TransactionKey>

Cancel an INVITE transaction using transaction-core

Properly cancels INVITE transactions while updating associated dialogs.

Source

pub fn get_transaction_statistics(&self) -> (usize, usize)

Get transaction statistics

Provides insight into transaction-dialog associations.

Source

pub async fn cleanup_orphaned_transaction_mappings(&self) -> usize

Cleanup orphaned transaction mappings

Removes transaction-dialog mappings for terminated dialogs.

Source§

impl DialogManager

INVITE-specific helper methods for DialogManager

Source

pub async fn handle_initial_invite( &self, transaction_id: TransactionKey, request: Request, source: SocketAddr, ) -> DialogResult<()>

Handle initial INVITE (dialog-creating)

Source

pub async fn handle_reinvite( &self, transaction_id: TransactionKey, request: Request, dialog_id: DialogId, ) -> DialogResult<()>

Handle re-INVITE (session modification)

Source

pub async fn process_ack_in_dialog( &self, request: Request, dialog_id: DialogId, ) -> DialogResult<()>

Process ACK within a dialog (related to INVITE processing)

Source§

impl DialogManager

BYE-specific helper methods for DialogManager

Source

pub async fn process_bye_in_dialog( &self, transaction_id: TransactionKey, request: Request, dialog_id: DialogId, ) -> DialogResult<()>

Process BYE within a dialog

Source§

impl DialogManager

REGISTER-specific helper methods for DialogManager

Source

pub fn extract_contact_uri(&self, request: &Request) -> Option<Uri>

Extract Contact URI from request

Source

pub fn extract_expires(&self, request: &Request) -> u32

Extract Expires value from request

Source

pub async fn send_basic_register_response( &self, transaction_id: &TransactionKey, request: &Request, expires: u32, ) -> DialogResult<()>

Send basic REGISTER response (for auto-response mode)

Source§

impl DialogManager

UPDATE-specific helper methods for DialogManager

Source

pub async fn process_update_in_dialog( &self, request: Request, dialog_id: DialogId, ) -> DialogResult<()>

Process UPDATE within a dialog

Source§

impl DialogManager

Response-specific helper methods for DialogManager

Source

pub async fn process_response_in_dialog( &self, response: Response, _transaction_id: TransactionKey, dialog_id: DialogId, ) -> DialogResult<()>

Process response within a dialog

Source

pub async fn handle_provisional_response( &self, response: Response, _transaction_id: TransactionKey, dialog_id: DialogId, ) -> DialogResult<()>

Handle provisional responses (1xx)

Source

pub async fn handle_success_response( &self, response: Response, transaction_id: TransactionKey, dialog_id: DialogId, ) -> DialogResult<()>

Handle successful responses (2xx)

Source

pub async fn handle_failure_response( &self, response: Response, transaction_id: TransactionKey, dialog_id: DialogId, ) -> DialogResult<()>

Handle failure responses (4xx, 5xx, 6xx)

Trait Implementations§

Source§

impl ByeHandler for DialogManager

Implementation of BYE handling for DialogManager

Source§

async fn handle_bye_method(&self, request: Request) -> DialogResult<()>

Handle BYE requests according to RFC 3261 Section 15

Terminates the dialog and sends appropriate responses.

Source§

impl Clone for DialogManager

Source§

fn clone(&self) -> DialogManager

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 DialogManager

Source§

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

Formats the value using the given formatter. Read more
Source§

impl DialogLookup for DialogManager

Source§

async fn find_dialog_for_request(&self, request: &Request) -> Option<DialogId>

Find an existing dialog by request

Implements RFC 3261 Section 12.2 dialog identification rules. Uses Call-ID, From tag, and To tag for proper dialog matching.

FIXED: Added fallback lookup for early dialogs that don’t have both tags yet.

Source§

async fn create_early_dialog_from_invite( &self, request: &Request, ) -> DialogResult<DialogId>

Create an early dialog from an INVITE request

Implements RFC 3261 Section 12.1.1 for early dialog creation. Early dialogs are created when processing incoming INVITE requests.

Source§

impl DialogMatcher for DialogManager

Source§

fn match_transaction( &self, transaction_id: &TransactionKey, ) -> DialogResult<DialogId>

Match a transaction to its associated dialog
Source§

impl DialogStore for DialogManager

Source§

async fn create_dialog(&self, request: &Request) -> DialogResult<DialogId>

Create a new dialog from an incoming request

Implements RFC 3261 Section 12.1.1 for UAS dialog creation. Creates an early dialog that can be confirmed later.

Source§

async fn create_outgoing_dialog( &self, local_uri: Uri, remote_uri: Uri, call_id: Option<String>, ) -> DialogResult<DialogId>

Create an outgoing dialog for client-initiated requests

Implements RFC 3261 Section 12.1.2 for UAC dialog creation. Creates an early dialog that will be confirmed by the response.

Source§

async fn store_dialog(&self, dialog: Dialog) -> DialogResult<()>

Store a dialog in the manager

Implements proper dialog storage with RFC 3261 compliant lookup keys.

Source§

fn get_dialog(&self, dialog_id: &DialogId) -> DialogResult<Dialog>

Get a dialog (read-only)

Source§

fn get_dialog_mut( &self, dialog_id: &DialogId, ) -> DialogResult<RefMut<'_, DialogId, Dialog>>

Get a mutable reference to a dialog

Source§

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

Terminate a dialog

Implements RFC 3261 Section 12.3 dialog termination. Properly cleans up all dialog state and lookup entries.

Source§

fn list_dialogs(&self) -> Vec<DialogId>

List all active dialogs

Source§

fn dialog_count(&self) -> usize

Get current dialog count

Source§

fn has_dialog(&self, dialog_id: &DialogId) -> bool

Check if a dialog exists

Source§

fn get_dialog_state(&self, dialog_id: &DialogId) -> DialogResult<DialogState>

Get dialog state

Source§

async fn update_dialog_state( &self, dialog_id: &DialogId, new_state: DialogState, ) -> DialogResult<()>

Update dialog state with proper notifications

Updates dialog state and notifies session-core of the change. Implements proper RFC 3261 state transition validation.

Source§

impl EventSender for DialogManager

Source§

async fn send_coordination_event( &self, event: SessionCoordinationEvent, ) -> DialogResult<()>

Send session coordination event
Source§

impl InviteHandler for DialogManager

Implementation of INVITE handling for DialogManager

Source§

async fn handle_invite_method( &self, request: Request, source: SocketAddr, ) -> DialogResult<()>

Handle INVITE requests according to RFC 3261 Section 14

Supports both initial INVITE (dialog-creating) and re-INVITE (session modification).

Source§

impl MessageRouter for DialogManager

Source§

async fn route_request(&self, request: &Request) -> Option<DialogId>

Route an incoming request to the appropriate dialog
Source§

impl MethodHandler for DialogManager

Implementation of MethodHandler for DialogManager

Source§

async fn handle_register_method( &self, request: Request, source: SocketAddr, ) -> DialogResult<()>

Delegate REGISTER handling to the specialized register_handler module

Source§

async fn handle_info_method( &self, request: Request, source: SocketAddr, ) -> DialogResult<()>

Handle INFO requests (simple forwarding to session layer)

Source§

async fn handle_refer_method( &self, request: Request, source: SocketAddr, ) -> DialogResult<()>

Handle REFER requests (call transfer)

Source§

async fn handle_subscribe_method( &self, request: Request, source: SocketAddr, ) -> DialogResult<()>

Handle SUBSCRIBE requests (simple forwarding to session layer)

Source§

async fn handle_notify_method( &self, request: Request, source: SocketAddr, ) -> DialogResult<()>

Handle NOTIFY requests (simple forwarding to session layer)

Source§

impl ProtocolHandlers for DialogManager

Implementation of ProtocolHandlers for DialogManager using specialized modules

Source§

async fn handle_invite_method( &self, request: Request, source: SocketAddr, ) -> DialogResult<()>

Delegate INVITE handling to the specialized invite_handler module

Source§

async fn handle_bye_method(&self, request: Request) -> DialogResult<()>

Delegate BYE handling to the specialized bye_handler module

Source§

async fn handle_cancel_method(&self, request: Request) -> DialogResult<()>

Handle CANCEL requests (not yet moved to specialized module)

Source§

async fn handle_ack_method(&self, request: Request) -> DialogResult<()>

Handle ACK requests (related to INVITE processing)

Source§

async fn handle_options_method( &self, request: Request, source: SocketAddr, ) -> DialogResult<()>

Handle OPTIONS requests with unified configuration support

Source§

async fn handle_update_method(&self, request: Request) -> DialogResult<()>

Delegate UPDATE handling to the specialized update_handler module

Source§

async fn handle_response_message( &self, response: Response, transaction_id: TransactionKey, ) -> DialogResult<()>

Delegate response handling to the specialized response_handler module

Source§

impl RegisterHandler for DialogManager

Implementation of REGISTER handling for DialogManager

Source§

async fn handle_register_method( &self, request: Request, source: SocketAddr, ) -> DialogResult<()>

Handle REGISTER requests according to RFC 3261 Section 10 with unified configuration support

REGISTER requests don’t create dialogs but are handled for completeness. Supports auto-response behavior based on unified configuration.

Source§

impl ResponseHandler for DialogManager

Implementation of response handling for DialogManager

Source§

async fn handle_response_message( &self, response: Response, transaction_id: TransactionKey, ) -> DialogResult<()>

Handle responses to client transactions

Processes responses and updates dialog state accordingly.

Source§

impl SessionCoordinator for DialogManager

Source§

async fn configure_session_coordination( &self, sender: Sender<SessionCoordinationEvent>, )

Set up session coordination channel
Source§

async fn notify_session_layer( &self, event: SessionCoordinationEvent, ) -> DialogResult<()>

Send event to session-core
Source§

impl TransactionHelpers for DialogManager

Associate a transaction with a dialog

Creates the mapping between transactions and dialogs for proper message routing.

Source§

async fn create_ack_for_success_response( &self, original_invite_tx_id: &TransactionKey, response: &Response, ) -> DialogResult<Request>

Create ACK for 2xx response using transaction-core helpers

Uses transaction-core’s ACK creation helpers while maintaining dialog-core concerns.

Source§

impl TransactionIntegration for DialogManager

Source§

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

Send a request within a dialog using transaction-core

Implements proper request creation within dialogs using Phase 3 dialog functions for significantly simplified and more maintainable code.

Source§

async fn send_transaction_response( &self, transaction_id: &TransactionKey, response: Response, ) -> DialogResult<()>

Send a response using transaction-core

Delegates response sending to transaction-core while maintaining dialog state.

Source§

impl UpdateHandler for DialogManager

Implementation of UPDATE handling for DialogManager

Source§

async fn handle_update_method(&self, request: Request) -> DialogResult<()>

Handle UPDATE requests according to RFC 3311

Provides session modification within dialogs.

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,