Search code examples
c#ucma

c# Terminate a transfer in UCMA 5


How do I end the running call transfer after a few seconds? In the documentation, the minimum call transfer duration is one minute (CallTransferOptions.MaximumTransferTime). In my application, there is a list of users on which the incoming call is transferred in the order listed. But wait a minute too long. My code example:

for (int i = 0; i < _targetsUri.Length; i++)
{
    try
    {
        _transferType.MaximumTransferTime = new TimeSpan(0, 0, 1, 0, 0);                   
        var handler = _audioVideoCall.BeginTransfer(_targetsUri[i], _transferType, null, _audioVideoCall);                    
        EndTransferCall(handler);                    
        _waitForTransferComplete.WaitOne();
    }
    catch (Exception ex)
    {
       ///
    }
} 

I want to end the call transfer to the current user after 20 seconds and start transfering to another in the next cycle of iteration. Now the call is transfered in a minute.


Solution

  • To do what you want to do you need to understand that in a attended blind transfer there are two calls going on while the attended blind transfer is in progress. The original call between yourself and the remote party and the new call between the remote party and the new destination.

    Other than the limitations of the MaximumTransferTime option, the only way to "terminate" the new transferring call is either:

    1. From the remote party end (i.e. hangup call)
    2. From the new destination end (i.e. reject call)

    This can't be done within your UCMA application. So you will have to either live with the MaximumTransferTime option limitations or the solution becomes more complex.

    If you really wanted to do this you need to write a Lync Server application (basically a SIP Proxy plugin). In the Lync Server application I would determine that this is one of those transferring calls and fork it to your UCMA application that times out the ringing phase and terminates the fork in some sort of special way. The Lync Server application could then "detect" the special failure (or any failure for that matter) and then redirect the call to the "next" target until it rang out of targets.

    There is a non-trivial amount of code required to do this but it can be done if required. I have helped to do similar things so I know the above solution can work.