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

# CallRexStateServiceProxy

`CallRexStateServiceProxy` is the WCF duplex client proxy for the CallRex real-time agent-state feed. It registers/unregisters live call-state monitoring for a single client, and exposes a synchronous poll variant used by [OP-AV-07 Real-time call-state monitoring](../../operations/real-time-call-state-monitoring.md). It is wrapped by [CallRecordingSystem](../services-utilities-audiovideo/CallRecordingSystem.md).

## Purpose
- Establish a WSDualHttpBinding duplex connection to the CallRex `AgentStateServiceClient`, delivering real-time call-state push notifications to a supplied [AgentStateCallback](AgentStateCallback.md).
- Provide a one-shot synchronous method to poll all monitored users' current call state without maintaining an ongoing registration.

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

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| (constructor) | `public CallRexStateServiceProxy(string serviceUrl, ILogService logSvc, AgentStateCallback callback)` | Configures a `WSDualHttpBinding` (10-minute receive timeout, ordered reliable session) and constructs the duplex `AgentStateServiceClient` bound to `callback`. |
| Register | `public void Register(CallUser user, Guid clientToken)` | Adds `user.Id` to the callback's monitored-user list, registers for the realtime feed filtered to that user, and immediately raises the user's current state via the callback. |
| GetAllUsersCurrentCallState | `public IEnumerable<CallMonitorState> GetAllUsersCurrentCallState(CallUser requestingUser)` | Registers for a one-time realtime-feed snapshot under a fresh client token, immediately unregisters, and maps each vendor state to a `CallMonitorState`. |
| Unregister | `public void Unregister(Guid clientToken)` | Unregisters the given client token from the realtime feed. |
| Dispose | `public void Dispose()` (from `IDisposable`) | Closes the underlying `AgentStateServiceClient` WCF channel. |

## Behavioral notes
- `Register` and `GetAllUsersCurrentCallState` both translate the vendor's `CallStateType` (`OnPhone`, `Recording`) into the library's `CallState` enum, defaulting to `Idle` for any other vendor value.
- `Register` mutates the shared `AgentStateCallback.UserIdsToMonitor` list supplied at construction, meaning multiple `Register` calls against the same callback instance accumulate monitored users rather than replacing the set.*

## Constraints and usage notes
- Constructor arguments `serviceUrl`, `logSvc`, and `callback` must all be non-null/non-empty (`Enforce.ArgumentNotNullOrEmpty`/`Enforce.ArgumentNotNull`).
- Instances should be disposed after use to close the underlying duplex WCF channel.

> **Note:** Statements marked with `*` were inferred from code structure, naming
> conventions, or contextual evidence where direct confirmation was not available
> in source artifacts.

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