I have a b2b call with self transfer. If there is no answer or agent becomes busy and can not answer the call I want to redirect to another free agent. I s subscribed to ProvisionalResponseReceived for the outgoing call leg and also to StateChanged. So I can see when call is ringing and when it transition from ringing to terminating. How can I deflect/forward this call to another agent before call enters terminating state.Is there any way to calculate ring duration? Or set a limit for ringing before I can transfer it further?
// Create the outbound call between UCMA and the agent.
_outboundAVCall = new AudioVideoCall(_outboundConversation);
// Register for notification of the StateChanged event on the outbound call.
_outboundAVCall.StateChanged += new EventHandler<CallStateChangedEventArgs>(outboundAVCall_StateChanged);
_outboundAVCall.ProvisionalResponseReceived += new EventHandler<CallProvisionalResponseReceivedEventArgs>(OnOutProvisionalResponseReceived);
//_outboundAVCall.
InitiateBackToBackCall(incomingCall, _outboundAVCall);
_outboundCallLeg = new BackToBackCallSettings(outboundCall, _destinationSipUrit);
incomingCall.StateChanged += new EventHandler<CallStateChangedEventArgs>(inboundAVCall_StateChanged);
incomingCall.ProvisionalResponseReceived += new EventHandler<CallProvisionalResponseReceivedEventArgs>(OnInProvisionalResponseReceived);
// incomingCallLeg.StateChanged += OnCallStateChanged;
// Create a new conversation for the incoming call leg.
_inboundConversation = new Conversation(incomingCall.Conversation.Endpoint);
_inboundCallLeg = new BackToBackCallSettings(incomingCall);
LogHelper.Log(LogTarget.FileEvent, "Status of incomming call:" + incomingCall.State.ToString());
LogHelper.Log(LogTarget.FileEvent, "Status of incommoutgoing call:" + outboundCall.State.ToString());
// Create the back-to-back call instance.
// Note that you need a Destination URI for the outgoing call leg, but not for the incoming call leg.
_b2bCall = new BackToBackCall(_inboundCallLeg, _outboundCallLeg);
// Begin the back-to-back session; provide a destination.
try
{
IAsyncResult result = _b2bCall.BeginEstablish(BeginEstablishCB, _b2bCall);
/* IAsyncResult result = _b2bCall.BeginEstablish(
delegate(IAsyncResult ar)
{
_b2bCall.EndEstablish(ar);
_waitForB2BCallToEstablish.Set();
}, _b2bCall);*/
}
catch (InvalidOperationException ioe)
{
LogHelper.Log(LogTarget.FileEvent, "_b2bCall must be in the Idle state." + ioe.Message.ToString(),1);
}
_waitForB2BCallToEstablish.WaitOne();
I had to add the code to handle the exception that will occur
After adding the above code I get it working.
Thanks.