예제 #1
0
        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);
                }
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        internal IAsyncResult BeginEstablishMohChannel(AcdServiceChannel channel, AsyncCallback userCallback, object state)
        {
            EstablishMoHChannelAsyncResult ar = new EstablishMoHChannelAsyncResult(this, channel, userCallback, state);

            lock (_syncRoot)
            {
                if (_state == MusicOnHoldServerState.Started)
                {
                    ThreadPool.QueueUserWorkItem((waitState) =>
                    {
                        var tempAr = waitState as EstablishMoHChannelAsyncResult;
                        tempAr.Process();
                    }, ar);
                }
                else
                {
                    throw new InvalidOperationException("AcdMusicOnHoldServer is in an invalid State to start a new Moh channel.");
                }
            }

            return(ar);
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        internal void EndEstablishMohChannel(IAsyncResult ar)
        {
            EstablishMoHChannelAsyncResult result = ar as EstablishMoHChannelAsyncResult;

            result.EndInvoke();
        }