Struct CallCenterClient

Source
pub struct CallCenterClient { /* private fields */ }
Expand description

§Call Center Client for Agent Applications

The CallCenterClient provides a simplified, high-level interface for agent applications to interact with the call center system. It abstracts complex orchestration details and provides essential functionality through an ergonomic API.

§Core Capabilities

§Agent Management

  • Registration: Register agent profiles with the call center
  • Status Updates: Update agent availability and activity status
  • Information Retrieval: Get current agent status and performance data

§System Integration

  • Queue Monitoring: Access queue statistics and performance metrics
  • Session Access: Direct access to underlying session management
  • Event Handling: Integration with call and system event processing

§Architecture

The client maintains a connection to the underlying CallCenterEngine which handles all orchestration, routing, and coordination. This design allows agent applications to focus on user interface and business logic while leaving complex call center operations to the engine.

§Thread Safety

The CallCenterClient is thread-safe and can be cloned for use across multiple components or tasks. All operations are asynchronous and designed for concurrent access.

§Examples

§Basic Client Usage

use rvoip_call_engine::api::CallCenterClient;
use rvoip_call_engine::agent::{Agent, AgentStatus};
use rvoip_call_engine::config::CallCenterConfig;
 
// Create and configure client
let client = CallCenterClient::builder()
    .with_config(CallCenterConfig::default())
    .build()
    .await?;
 
// Register agent
let agent = Agent {
    id: "agent-001".to_string(),
    sip_uri: "sip:agent@call-center.com".to_string(),
    display_name: "Agent Smith".to_string(),
    skills: vec!["general".to_string()],
    max_concurrent_calls: 1,
    status: AgentStatus::Available,
    department: None,
    extension: None,
};
 
let session_id = client.register_agent(&agent).await?;
println!("Agent registered with session: {}", session_id);

Implementations§

Source§

impl CallCenterClient

Source

pub fn new(engine: Arc<CallCenterEngine>) -> Self

Create a new call center client connected to the given engine

Initializes a new client instance that connects to the specified call center engine. The client provides a simplified interface for agent applications while leveraging the full capabilities of the underlying engine.

§Arguments
  • engine - Shared reference to the call center engine
§Examples
use rvoip_call_engine::api::CallCenterClient;
use rvoip_call_engine::CallCenterEngine;
use rvoip_call_engine::config::CallCenterConfig;
use std::sync::Arc;
 
let engine = CallCenterEngine::new(
    CallCenterConfig::default(),
    None
).await?;
 
let client = CallCenterClient::new(engine);
Source

pub async fn register_agent(&self, agent: &Agent) -> CallCenterResult<SessionId>

Register an agent with the call center

Registers a new agent profile with the call center system, establishing a session and making the agent available for call routing. This is the primary method for agent onboarding and authentication.

§Arguments
  • agent - Complete agent profile including identification, skills, and status
§Returns

Ok(SessionId) with the assigned session identifier if registration succeeds, or error if registration fails.

§Examples
use rvoip_call_engine::api::CallCenterClient;
use rvoip_call_engine::agent::{Agent, AgentStatus};
 
 
let agent = Agent {
    id: "agent001".to_string(),
    sip_uri: "sip:agent001@example.com".to_string(),
    display_name: "Agent 001".to_string(),
    skills: vec!["sales".to_string(), "support".to_string()],
    max_concurrent_calls: 3,
    status: AgentStatus::Available,
    department: Some("sales".to_string()),
    extension: Some("001".to_string()),
};
 
let session_id = client.register_agent(&agent).await?;
println!("Agent registered with session: {}", session_id);
 
// Agent is now ready to receive calls
println!("🟢 {} is available for calls", agent.display_name);
Source

pub async fn update_agent_status( &self, agent_id: &AgentId, status: AgentStatus, ) -> CallCenterResult<()>

Update agent status

Changes the operational status of an agent, affecting their availability for call routing. This method is used to reflect changes in agent availability, breaks, or shift changes.

§Arguments
  • agent_id - Identifier of the agent to update
  • status - New status for the agent
§Returns

Ok(()) if status update succeeds, or error if update fails.

§Examples
use rvoip_call_engine::api::CallCenterClient;
use rvoip_call_engine::agent::{AgentId, AgentStatus};
 
 
let agent_id = AgentId::from("agent001");
 
// Mark agent as offline for lunch break
client.update_agent_status(&agent_id, AgentStatus::Offline).await?;
println!("🔴 Agent offline for lunch break");
 
// Mark agent as available after break
client.update_agent_status(&agent_id, AgentStatus::Available).await?;
println!("🟢 Agent back and available for calls");
 
// Handle end-of-shift
client.update_agent_status(&agent_id, AgentStatus::Offline).await?;
println!("👋 Agent signed off for the day");
Source

pub async fn get_agent_info(&self, agent_id: &AgentId) -> Option<AgentInfo>

Get current agent information

Retrieves comprehensive information about an agent including their current status, active calls, performance metrics, and capabilities. This method is essential for agent monitoring and dashboard displays.

§Arguments
  • agent_id - Identifier of the agent to retrieve
§Returns

Some(AgentInfo) with current agent information if found, None if agent doesn’t exist.

§Examples
use rvoip_call_engine::api::CallCenterClient;
use rvoip_call_engine::agent::AgentId;
 
 
let agent_id = AgentId::from("agent001");
 
if let Some(agent_info) = client.get_agent_info(&agent_id).await {
    println!("📋 Agent Information:");
    println!("  Agent ID: {}", agent_info.agent_id.0);
    println!("  Status: {:?}", agent_info.status);
    println!("  Active calls: {}", agent_info.current_calls);
    println!("  Performance: {:.1}%", agent_info.performance_score * 100.0);
    println!("  Skills: {:?}", agent_info.skills);
     
    // Check for performance issues
    if agent_info.performance_score < 0.7 {
        println!("⚠️ Performance below threshold - coaching may be needed");
    }
     
    // Check workload
    if agent_info.current_calls > 2 {
        println!("📞 High call volume - {} active calls", agent_info.current_calls);
    }
} else {
    println!("❌ Agent not found or not registered");
}
Source

pub async fn get_queue_stats( &self, ) -> CallCenterResult<Vec<(String, QueueStats)>>

Get current queue statistics

Returns comprehensive statistics for all queues that the agent has visibility into. This provides essential context for agent applications to understand system load and performance.

§Returns

Ok(Vec<(String, QueueStats)>) with queue name and statistics pairs, or error if statistics retrieval fails.

§Examples
use rvoip_call_engine::api::CallCenterClient;
 
 
let queue_stats = client.get_queue_stats().await?;
 
println!("📊 Queue Statistics:");
for (queue_id, stats) in &queue_stats {
    println!("  Queue: {}", queue_id);
    println!("    Total calls: {}", stats.total_calls);
    println!("    Avg wait: {}s", stats.average_wait_time_seconds);
    println!("    Longest wait: {}s", stats.longest_wait_time_seconds);
     
    // Alert on concerning conditions
    if stats.total_calls > 10 {
        println!("    🚨 High queue volume!");
    }
     
    if stats.longest_wait_time_seconds > 300 {
        println!("    ⏰ Long wait times detected!");
    }
     
    // Show utilization info
    println!("    Queue utilization: {} calls", stats.total_calls);
}
 
// Summary statistics
let total_calls: usize = queue_stats.iter()
    .map(|(_, stats)| stats.total_calls)
    .sum();
 
println!("\n📈 System Summary:");
println!("  Total queued calls: {}", total_calls);
println!("  Active queues: {}", queue_stats.len());
Source

pub fn session_manager(&self) -> &Arc<SessionCoordinator>

Get the underlying session manager for advanced operations

Provides direct access to the session-core functionality for applications that need to perform advanced session management operations beyond the simplified client API.

§Returns

Reference to the underlying SessionCoordinator instance.

§Examples
use rvoip_call_engine::api::CallCenterClient;
 
 
// Access session manager for advanced operations
let session_manager = client.session_manager();
 
// Access advanced session manager functionality
println!("🔧 Advanced Session Information:");
println!("  Session manager available for advanced operations");
// Note: Use session_manager methods like create_session, bridge_sessions, etc.
 
// Access session-core capabilities directly
// let bridges = session_manager.list_bridges().await?;
// let session_details = session_manager.get_session_details(&session_id).await?;
 
println!("🚀 Advanced session capabilities available");
Source

pub fn call_handler(&self) -> Arc<dyn CallHandler>

Get the call handler for this client

Returns a call handler that can be used for advanced call event processing and integration with the session framework. This enables sophisticated call handling scenarios beyond basic agent operations.

§Returns

Arc<dyn CallHandler> that implements call event handling for the call center.

§Examples
use rvoip_call_engine::api::CallCenterClient;
use rvoip_session_core::CallHandler;
 
 
// Get call handler for advanced call processing
let call_handler = client.call_handler();
 
println!("📞 Call handler available for advanced integration");
 
// In practice, you might:
// - Register this handler with the session manager
// - Use it for custom call event processing
// - Integrate with external systems or workflows
 
// Example of potential usage:
// session_manager.register_call_handler(call_handler).await?;
Source

pub fn builder() -> CallCenterClientBuilder

Create a builder for constructing a CallCenterClient

Returns a CallCenterClientBuilder that provides a fluent interface for configuring and creating a client instance. This is the recommended way to create clients with custom configuration.

§Returns

CallCenterClientBuilder instance ready for configuration.

§Examples
use rvoip_call_engine::api::CallCenterClient;
use rvoip_call_engine::config::CallCenterConfig;
 
let client = CallCenterClient::builder()
    .with_config(CallCenterConfig::default())
    .with_database_path("call_center.db".to_string())
    .build()
    .await?;
 
println!("✅ Call center client ready");

Trait Implementations§

Source§

impl Clone for CallCenterClient

Source§

fn clone(&self) -> CallCenterClient

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

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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,

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,