Exemplo n.º 1
0
 internal TerminateMoHChannelAsyncResult(
     AcdMusicOnHoldServer mohServer,
     AcdServiceChannel channel,
     AsyncCallback userCallback,
     object state) : base(userCallback, state)
 {
     _mohServer  = mohServer;
     _mohChannel = channel;
 }
Exemplo n.º 2
0
 internal void RemoveServiceChannel(AcdServiceChannel serviceChannel)
 {
     lock (_syncRoot)
     {
         if (serviceChannel.IsPrimaryServiceChannel)
         {
             _isPrimaryChannelCreated = false;
         }
         _listOfServiceChannels.Remove(serviceChannel);
     }
 }
Exemplo n.º 3
0
 internal void AddServiceChannel(AcdServiceChannel serviceChannel)
 {
     lock (_syncRoot)
     {
         if (serviceChannel.IsPrimaryServiceChannel)
         {
             if (_isPrimaryChannelCreated == true)
             {
                 throw new InvalidOperationException("AcdConferenceServicesAnchor already has a primary channel created");
             }
             else
             {
                 _isPrimaryChannelCreated = true;
             }
         }
         _listOfServiceChannels.Add(serviceChannel);
     }
 }
Exemplo n.º 4
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);
                }
            }
        }
Exemplo n.º 5
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);
            }
        }
Exemplo n.º 6
0
        internal IAsyncResult BeginTerminateMohChannel(AcdServiceChannel channel, AsyncCallback userCallback, object state)
        {
            TerminateMoHChannelAsyncResult ar = new TerminateMoHChannelAsyncResult(this, channel, userCallback, state);

            lock (_syncRoot)
            {
                if (_state == MusicOnHoldServerState.Started)
                {
                    ThreadPool.QueueUserWorkItem((waitState) =>
                    {
                        var tempAr = waitState as TerminateMoHChannelAsyncResult;
                        tempAr.Process();
                    }, ar);
                }
                else
                {
                    throw new InvalidOperationException("AcdMusicOnHoldServer is shutting down or in an invalid state to perform this action.");
                }
            }

            return(ar);
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
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);
            }
        }