コード例 #1
0
ファイル: AcdMusicOnHoldServer.cs プロジェクト: mujiansu/Lync
        private void StartUpMohChannelCompleted(IAsyncResult result)
        {
            object[] args = result.AsyncState as object[];

            AcdServiceChannel musicChannel   = args[0] as AcdServiceChannel;
            string            participantUri = args[1] as String;
            CallReceivedEventArgs <AudioVideoCall> callReceivedArgs = args[2] as CallReceivedEventArgs <AudioVideoCall>;
            EstablishMoHChannelAsyncResult         ear = args[3] as EstablishMoHChannelAsyncResult;

            try
            {
                musicChannel.EndStartUp(result);

                try
                {
                    musicChannel.BeginEstablishPrivateAudioChannel(participantUri,
                                                                   true /*outsideMix*/,
                                                                   EstablishPrivateAudioChannelCompleted,
                                                                   musicChannel);
                }
                catch (InvalidOperationException ivoex)
                {
                    musicChannel.BeginShutDown(dar =>
                    {
                        AcdServiceChannel channel = dar.AsyncState as AcdServiceChannel;
                        channel.EndShutDown(dar);
                    },
                                               musicChannel);

                    ear.SetAsCompleted(new OperationFailureException("AcdMusicOnHoldServer failed begin establishing private audio channel", ivoex), false);
                }
            }
            catch (RealTimeException rtex)
            {
                callReceivedArgs.Call.Decline();
                ear.SetAsCompleted(rtex, false);
            }
        }
コード例 #2
0
ファイル: AcdMusicOnHoldServer.cs プロジェクト: mujiansu/Lync
        private void CompleteGetMohCallAsyncResult(
            object sender,
            CallReceivedEventArgs <AudioVideoCall> callReceivedArgs)
        {
            if (object.ReferenceEquals(callReceivedArgs.Call.Conversation.ApplicationContext, this))
            {
                EstablishMoHChannelAsyncResult result = null;
                lock (_syncRoot)
                {
                    try
                    {
                        result = _listOfPendingMohCallAsyncResults.First <EstablishMoHChannelAsyncResult>();
                    }
                    catch (InvalidOperationException)
                    {
                        return;
                    }
                    _listOfPendingMohCallAsyncResults.Remove(result);
                }

                AcdServiceChannel mohChannel = new AcdServiceChannel(result.Anchor, _logger);

                try
                {
                    object[] args = new object[4];
                    args[0] = mohChannel;
                    args[1] = result.ParticipantUri;
                    args[2] = callReceivedArgs;
                    args[3] = result;

                    mohChannel.BeginStartUp(callReceivedArgs.Call,
                                            ServiceChannelType.DialIn,
                                            McuMediaChannelStatus.None,
                                            this.StartUpMohChannelCompleted,
                                            args);
                }
                catch (InvalidOperationException ivoex)
                {
                    callReceivedArgs.Call.Decline();
                    result.SetAsCompleted(new OperationFailureException("AcdMusicOnHoldServer failed begin starting up the MOH channel", ivoex), false);
                }
            }
        }
コード例 #3
0
ファイル: AcdMusicOnHoldServer.cs プロジェクト: mujiansu/Lync
        private static void EstablishPrivateAudioChannelCompleted(
            IAsyncResult result)
        {
            AcdServiceChannel musicChannel     = result.AsyncState as AcdServiceChannel;
            EstablishMoHChannelAsyncResult ear = result as EstablishMoHChannelAsyncResult;

            try
            {
                musicChannel.EndEstablishPrivateAudioChannel(result);
            }
            catch (RealTimeException rtex)
            {
                musicChannel.BeginShutDown(dar =>
                {
                    AcdServiceChannel channel = dar.AsyncState as AcdServiceChannel;
                    channel.EndShutDown(dar);
                },
                                           musicChannel);
                ear.SetAsCompleted(rtex, false);
            }
        }