internal TerminateMoHChannelAsyncResult( AcdMusicOnHoldServer mohServer, AcdServiceChannel channel, AsyncCallback userCallback, object state) : base(userCallback, state) { _mohServer = mohServer; _mohChannel = channel; }
internal void RemoveServiceChannel(AcdServiceChannel serviceChannel) { lock (_syncRoot) { if (serviceChannel.IsPrimaryServiceChannel) { _isPrimaryChannelCreated = false; } _listOfServiceChannels.Remove(serviceChannel); } }
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); } }
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); } } }
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); } }
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); }
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); }
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); } }