使用ucma 5.0

时间:2016-08-15 18:19:49

标签: c# lync ivr ucma skype-for-business

我正在为buisienss和UCMA 5.0开发基于skype的自定义IVR系统

在我的应用程序中,我使用begintransfer方法将呼叫转移到用户。 当我从Skype客户端内部呼叫时,一切正常,呼叫路由正确。 来自pstn网关呼叫的入站呼叫被应答,并且无需异常执行begintransfer,但呼叫不会路由到分机。

这是我的代码: call.BeginTransfer()

我不能使用转发(而不是转移),因为当呼叫尚未建立时,转发工作。我需要播放录音并为没有IVR的转接电话做出选择。

我想我在“_toneController_ToneReceived”事件中遗漏了一些东西

我做错了什么?

enter image description here

public class IVR
{

    private static void _toneController_ToneReceived(object sender, ToneControllerEventArgs e)
        {

            number += getToneString(tone);

            if (number.Length == 3)
            {
                try
                {    
                    CallTransferOptions unattendedTransferOptions = new CallTransferOptions(CallTransferType.Unattended);

                    //  currentCall.BeginTransfer(number, unattendedTransferOptions, TransferCallBack, null);
                    //currentCall.BeginTransfer(number , null,null);//, EndEndpointEstablish, new object());

                    currentCall.BeginTransfer(
                                       number,
                                       new CallTransferOptions(CallTransferType.Attended),
                                       result =>
                                       {
                                           try
                                           {
                                               currentCall.EndTransfer(result);
                                           }
                                           catch (OperationFailureException ofe)
                                           {
                                               Logger_Call.log(string.Format("The recipient declined or did not answer the call:{0}",
                                                   ofe));
                                           }
                                           catch (RealTimeException rte)
                                           {
                                               Logger_Call.log(string.Format("Error transferring call:{0}", rte));
                                           }
                                       }, null);


                    Logger_Call.log(currentCall.OriginalDestinationUri + " ==> " + number);
                }
                catch (Exception ex)
                {
                    Logger_Call.log(currentCall.OriginalDestinationUri + " ==ex==> " + ex.Message);
                }
            }

        }

    private void InitializeCallReceive(string applicationUri, string serverName, int serverPort, NetworkCredential credential)
    {
        try
        {
            Debugger.Launch();

            ClientPlatformSettings clientPlatformSettings;
            clientPlatformSettings = new ClientPlatformSettings("IVR.Server", SipTransportType.Tls);

            collaborationPlatform = new CollaborationPlatform(clientPlatformSettings);
            collaborationPlatform.EndStartup(collaborationPlatform.BeginStartup(null, null));

            UserEndpointSettings endpointSettings;

            endpointSettings = new UserEndpointSettings(applicationUri, serverName, serverPort);


            endpoint = new UserEndpoint(collaborationPlatform, endpointSettings);


            endpoint.Credential = credential;

            endpoint.RegisterForIncomingCall<AudioVideoCall>(AudioVideoCallReceived);

            endpoint.EndEstablish(endpoint.BeginEstablish(null, endpoint));
        }
        catch (Exception ex)
        {
        }
    }


    private void AudioVideoCallReceived(object sender, CallReceivedEventArgs<AudioVideoCall> e)
    {
        currentCall = e.Call;

        currentCall.AudioVideoFlowConfigurationRequested += new EventHandler<AudioVideoFlowConfigurationRequestedEventArgs>(Call_AudioVideoFlowConfigurationRequested);


        currentCall.EndAccept(currentCall.BeginAccept(null, null));

    }
    private void Call_AudioVideoFlowConfigurationRequested(object sender, AudioVideoFlowConfigurationRequestedEventArgs e)
    {
        currentCall.Flow.StateChanged += new EventHandler<MediaFlowStateChangedEventArgs>(Flow_StateChanged);
    }
    private void Flow_StateChanged(object sender, MediaFlowStateChangedEventArgs e)
    {
        _flow = (AudioVideoFlow)sender;

        if (e.State == MediaFlowState.Active)
        {
            try
            {
                ToneController _toneController = new ToneController();
                _toneController.ToneReceived += _toneController_ToneReceived;
                _toneController.AttachFlow(_flow);

                MediaSource source = new WmaFileSource("rec.wma");
                source.EndPrepareSource(source.BeginPrepareSource(MediaSourceOpenMode.Buffered, null, null));
                Player _player = new Player();
                _player.SetSource(source);

                _player.AttachFlow(_flow);
                _player.SetMode(PlayerMode.Automatic);

                _player.Start();
            }
            catch (Exception)
            {
            }
        }
    }





}

1 个答案:

答案 0 :(得分:0)

代码是正确的。 我在Skype服务器上设置错误。 要进行传输,必须在中继配置中启用引用支持

检查此链接: https://support.microsoft.com/en-us/kb/2506083

  

重要提示:

     

Lync Server全局,站点或池中继配置策略启用了启用引用支持选项

     

本地部署的IP网关或Internet服务提供商(ISP)SIP中继服务部署的IP网关不支持使用SIP REFER方法

<强> image of trunk configuration