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

# AgentStateCallback

`AgentStateCallback` is the WCF duplex callback implementation (`IAgentStateServiceCallback`) that receives real-time agent-state push notifications from CallRex and raises them as `CallMonitorState` events, filtered to a configurable set of monitored user IDs. It is supplied to [CallRexStateServiceProxy](CallRexStateServiceProxy.md) at construction and is the underlying mechanism behind [OP-AV-07 Real-time call-state monitoring](../../operations/real-time-call-state-monitoring.md).

## Purpose
- Implement the vendor's duplex callback contract to receive push notifications of user call-state changes.
- Filter incoming state changes to only the user IDs the caller has registered interest in, and translate vendor state values into the library's `CallState` enum.

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

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| CallStateChanged | `public CallStateChangedHandler CallStateChanged` (delegate event field) | Raised with a `CallMonitorState` when a monitored user's state changes. |
| UserIdsToMonitor | `public List<Guid> UserIdsToMonitor` | The set of vendor user IDs for which incoming state changes should raise `CallStateChanged`. |
| id | `public int id = 1` | Public instance field; usage/purpose beyond its default value is not evident from source.** |
| (constructor, default) | `public AgentStateCallback()` | Constructs an instance with an empty `UserIdsToMonitor` list. |
| (constructor, seeded) | `public AgentStateCallback(List<Guid> userIdsToMonitor)` | Constructs an instance pre-populated with the given monitored user IDs. |
| ReceiveState | `public void ReceiveState(RealtimeUserState userState)` (from `IAgentStateServiceCallback`) | Invoked by the WCF runtime on each vendor push; converts the state and raises `CallStateChanged` only if `userState.UserID` is in `UserIdsToMonitor`. |
| Convert | `public static CallMonitorState Convert(RealtimeUserState state)` | Maps a vendor `RealtimeUserState` to a `CallMonitorState`, translating `CallStateType` to `CallState` (defaulting to `Idle` for unmatched values). |

## Behavioral notes
- Every received state (whether filtered or not) is written to `Debug.WriteLine` for diagnostic purposes, independent of whether `CallStateChanged` is raised.
- `Convert` is also invoked directly by `CallRexStateServiceProxy.Register` to raise the requesting user's initial state immediately upon registration, and by its own instance method `ReceiveState`.

## Constraints and usage notes
- `ReceiveState` requires `userState` to be non-null (`Enforce.ArgumentNotNull`).
- `UserIdsToMonitor` and `CallStateChanged` are public mutable fields (not properties), so callers can add/remove monitored users or subscribe to the event directly.

> **Note:** Statements marked with `**` could not be confirmed from available
> source or analysis artifacts.

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