---
title: AgentStateCallback
summary: API reference for AgentStateCallback.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-15
library: SAIF.Application.Services.AudioVideo.32
reference_type: package
---

# AgentStateCallback

`AgentStateCallback` implements the generated WCF duplex callback contract `IAgentStateServiceCallback`, receiving real-time agent call-state notifications from the CallRex agent-state service and forwarding them to [CallRecordingSystem](../saif-services-utilities-audiovideo/CallRecordingSystem.md) via the `CallStateChanged` delegate; see [CallRex WCF proxy operations](../../operations/callrex-wcf-proxy-operations.md).

## Purpose
- Receives push notifications (`ReceiveState`) from the CallRex agent-state WCF service as agents' call states change.
- Converts the generated proxy's `RealtimeUserState` type into this library's own [CallMonitorState](../saif-core-contracts-audiovideo/CallMonitorState.md) DTO via the static `Convert` method.
- Filters notifications to only the users currently being monitored, via `UserIdsToMonitor`.

## Context
- Namespace: `SAIF.Services.ClientProxies.ThirdParty`
- Assembly/package: `SAIF.Application.Services.AudioVideo.32`
- Implements: generated `IAgentStateServiceCallback`

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| ReceiveState | `void ReceiveState(RealtimeUserState state)` | WCF duplex callback entry point invoked by the CallRex agent-state service when a monitored agent's state changes. |
| CallStateChanged | `delegate ... CallStateChanged` | Delegate invoked with the converted [CallMonitorState](../saif-core-contracts-audiovideo/CallMonitorState.md) so `CallRecordingSystem` can raise its own `OnCallStateChanged` event.* |
| UserIdsToMonitor | `IEnumerable<string> UserIdsToMonitor { get; set; }` | The set of user IDs this callback instance should forward state changes for.* |
| id | `Guid id` | Correlation/instance identifier for this callback registration.* |
| Convert (static) | `static CallMonitorState Convert(RealtimeUserState state)` | Maps the generated proxy's `RealtimeUserState` into this library's [CallMonitorState](../saif-core-contracts-audiovideo/CallMonitorState.md) DTO. |

## Behavioral notes
- Registered with the CallRex agent-state service by `CallRexStateServiceProxy.Register`; `ReceiveState` calls trigger `CallStateChanged`, which `CallRecordingSystem.CallState_Changed` subscribes to in order to raise its own `OnCallStateChanged` event.

## Constraints and usage notes
- Instances of this type are tied to the lifetime of the duplex WCF channel established by `CallRexStateServiceProxy`; they are not intended to be constructed or used independently of that proxy.*

> **Note:** Statements marked with `*` were inferred from code structure, naming conventions, or
> contextual evidence where direct confirmation was not available in source artifacts. Statements
> marked with `**` could not be confirmed; treat as unknown until verified.

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