---
title: Real-time call-state monitoring
summary: Registers, receives, and unregisters a live agent/call-state feed from the CallRex vendor system.
status: draft
owner: <owner>
last_reviewed: 2026-09-15
library: SAIF.Application.Services.AudioVideo
reference_type: package
operation_id: OP-AV-07
trigger: External caller (e.g., a live agent-monitoring UI) invokes CallRecordingSystem.StartMonitoring, StopMonitoring, or GetAllUsersCurrentCallState
---

# Real-time call-state monitoring

This operation family lets an external caller (e.g., a live agent-monitoring UI) subscribe to or poll real-time call-state updates for one or more users from the CallRex vendor system. Unlike the other operations in this library, it has no database interaction — it is a pure WCF pass-through to the vendor real-time feed.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-AV-07 |
| **Trigger** | External caller invokes `CallRecordingSystem.StartMonitoring(CallUser user)`, `StopMonitoring()`, or `GetAllUsersCurrentCallState(CallUser requestingUser)`. |
| **Inputs** | `CallUser` (subscribe/poll target) |
| **Outputs** | `OnCallStateChanged` events (subscribe path); `IEnumerable<CallMonitorState>` (poll path). |
| **Primary components** | `CallRecordingSystem.StartMonitoring` / `StopMonitoring` / `GetAllUsersCurrentCallState`, `CallRexStateServiceProxy`, `AgentStateCallback` |
| **Entry point** | `Application\SAIF.Application.Services.AudioVideo\Services\Utilities\AudioVideo\RecordingSystem.cs` |

## Steps

1. `StartMonitoring(CallUser user)` registers the caller's `_clientToken` and target `user` with `CallRexStateServiceProxy.Register`.
   - The proxy calls the vendor `AgentStateServiceClient.RegisterForRealtimeFeedOnReportsFiltered` and immediately raises the initial state through the `AgentStateCallback` duplex WCF callback contract.
2. Ongoing state changes arrive asynchronously via `AgentStateCallback.ReceiveState`, which filters to only the currently-monitored `UserIdsToMonitor` and raises `CallStateChanged` → `CallRecordingSystem.CallState_Changed` → the `OnCallStateChanged` event to the library's caller.
3. `StopMonitoring()` calls `CallRexStateServiceProxy.Unregister(_clientToken)`, which invokes the vendor `UnregisterForRealtimeFeed`.
4. `GetAllUsersCurrentCallState(CallUser requestingUser)` is a synchronous poll variant: it registers, immediately reads via the vendor `RegisterForRealtimeFeedOnReports`, unregisters, and maps each vendor `ExtendedRealtimeUserState` to a `CallMonitorState`.

## Process flow

The following diagram visualizes this operation family's control flow.

```mermaid
flowchart TD
	Start([StartMonitoring invoked]) --> Register[Register with CallRexStateServiceProxy]
	Register --> Vendor["Vendor: RegisterForRealtimeFeedOnReportsFiltered"]
	Vendor --> Callback[AgentStateCallback.ReceiveState]
	Callback --> Filter{User in UserIdsToMonitor?}
	Filter -->|Yes| Raise[Raise OnCallStateChanged]
	Filter -->|No| Ignore([Ignore update])
	Stop([StopMonitoring invoked]) --> Unregister[Unregister with CallRexStateServiceProxy]
	Poll([GetAllUsersCurrentCallState invoked]) --> RegisterPoll[Register] --> ReadPoll["Vendor: RegisterForRealtimeFeedOnReports"] --> UnregisterPoll[Unregister] --> Map[Map to CallMonitorState list]
```

## Failure and edge-case behavior
- No database interaction occurs in this operation family — it is purely a WCF pass-through to the vendor real-time feed.
- `CallRexStateServiceProxy` uses `WSDualHttpBinding` with security mode `None`, so the real-time duplex channel carries no transport or message security.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

## Sources
- `Application\SAIF.Application.Services.AudioVideo\Services\Utilities\AudioVideo\RecordingSystem.cs`
- `Application\SAIF.Application.Services.AudioVideo\Services\ClientProxies\ThirdParty\CallRexStateServiceProxy.cs`
- `Application\SAIF.Application.Services.AudioVideo\Services\ClientProxies\ThirdParty\AgentStateCallback.cs`
