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
impl CallCenterClient
Sourcepub fn new(engine: Arc<CallCenterEngine>) -> Self
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);
Sourcepub async fn register_agent(&self, agent: &Agent) -> CallCenterResult<SessionId>
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);
Sourcepub async fn update_agent_status(
&self,
agent_id: &AgentId,
status: AgentStatus,
) -> CallCenterResult<()>
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 updatestatus
- 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");
Sourcepub async fn get_agent_info(&self, agent_id: &AgentId) -> Option<AgentInfo>
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");
}
Sourcepub async fn get_queue_stats(
&self,
) -> CallCenterResult<Vec<(String, QueueStats)>>
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());
Sourcepub fn session_manager(&self) -> &Arc<SessionCoordinator>
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");
Sourcepub fn call_handler(&self) -> Arc<dyn CallHandler>
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?;
Sourcepub fn builder() -> CallCenterClientBuilder
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
impl Clone for CallCenterClient
Source§fn clone(&self) -> CallCenterClient
fn clone(&self) -> CallCenterClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for CallCenterClient
impl !RefUnwindSafe for CallCenterClient
impl Send for CallCenterClient
impl Sync for CallCenterClient
impl Unpin for CallCenterClient
impl !UnwindSafe for CallCenterClient
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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