internal void Process() { if (_anchor._conversation.State != ConversationState.Idle) { if (null != _anchor._conference) { _anchor._conversation.ConferenceSession.BeginTerminateConference(ar => { ConferenceSession confSession = ar.AsyncState as ConferenceSession; confSession.EndTerminateConference(ar); confSession.Conversation.Endpoint.ConferenceServices.BeginCancelConference(_anchor._conference.ConferenceId, cac => { ConferenceServices confServices = cac.AsyncState as ConferenceServices; try { confServices.EndCancelConference(cac); } catch (RealTimeException) { //TODO: trace statement } finally { this.SetAsCompleted(null, false); _anchor.UpdateState(ConferenceServicesAnchorState.Terminated); foreach (ShutDownAsyncResult sar in _anchor._listOfShutDownAsyncResults) { sar.SetAsCompleted(null, false); } } }, confSession.Conversation.Endpoint.ConferenceServices); }, _anchor._conversation.ConferenceSession); } else { _anchor.Conversation.BeginTerminate(ter => { _anchor.Conversation.EndTerminate(ter); _anchor.UpdateState(ConferenceServicesAnchorState.Terminated); foreach (ShutDownAsyncResult sar in _anchor._listOfShutDownAsyncResults) { sar.SetAsCompleted(null, false); } this.SetAsCompleted(null, false); }, null); } } else { _anchor.Conversation.BeginTerminate(ter => { _anchor.Conversation.EndTerminate(ter); _anchor.UpdateState(ConferenceServicesAnchorState.Terminated); foreach (ShutDownAsyncResult sar in _anchor._listOfShutDownAsyncResults) { sar.SetAsCompleted(null, false); } this.SetAsCompleted(null, false); }, null); } }
internal void Process() { if (String.IsNullOrEmpty(_anchor._conferenceUri)) { _anchor.AuthorizeParticipant(_presenterUri); _anchor.ElevateToPresenter(_presenterUri); ConferenceServices conferenceManagement = _anchor._endpoint.ConferenceServices; //Create a conference to anchor the incoming customer call ConferenceScheduleInformation conferenceScheduleInfo = new ConferenceScheduleInformation(); conferenceScheduleInfo.AutomaticLeaderAssignment = AutomaticLeaderAssignment.Disabled; conferenceScheduleInfo.LobbyBypass = LobbyBypass.Disabled; conferenceScheduleInfo.AccessLevel = ConferenceAccessLevel.Locked; conferenceScheduleInfo.PhoneAccessEnabled = false; conferenceScheduleInfo.Mcus.Add(new ConferenceMcuInformation(MediaType.ApplicationSharing)); conferenceScheduleInfo.Mcus.Add(new ConferenceMcuInformation(McuType.AudioVideo)); conferenceScheduleInfo.Mcus.Add(new ConferenceMcuInformation(McuType.InstantMessaging)); try { //schedule the conference conferenceManagement.BeginScheduleConference(conferenceScheduleInfo, ar => { try { _anchor._conference = conferenceManagement.EndScheduleConference(ar); } catch (RealTimeException rtex) { this.SetAsCompleted(rtex, false); return; } _anchor._conferenceUri = _anchor._conference.ConferenceUri; _anchor.RegisterForEvents(); //Join the conference as a trusted conferencing user (invisible in the roster) ConferenceJoinOptions options = new ConferenceJoinOptions(); options.JoinMode = JoinMode.TrustedParticipant; try { _anchor._conversation.ConferenceSession.BeginJoin(_anchor._conference.ConferenceUri, options, jar => { Conversation conv = jar.AsyncState as Conversation; try { conv.ConferenceSession.EndJoin(jar); //Update the state of the anchor when the operation succeeds _anchor.UpdateState(ConferenceServicesAnchorState.Established); this.SetAsCompleted(null, false); } catch (RealTimeException rtex) { if (null != _anchor) { _anchor._logger.Log("AcdConferenceServicesAnchor failed to create a conference", rtex); } _anchor.BeginShutDown(sar => { AcdConferenceServicesAnchor anchor = sar.AsyncState as AcdConferenceServicesAnchor; anchor.EndShutDown(sar); }, _anchor); this.SetAsCompleted(rtex, false); } } , _anchor._conversation); } catch (InvalidOperationException ivoex) { _anchor._logger.Log("AcdConferenceServicesAnchor failed to create a conference", ivoex); _anchor.BeginShutDown(sar => { AcdConferenceServicesAnchor anchor = sar.AsyncState as AcdConferenceServicesAnchor; anchor.EndShutDown(sar); }, _anchor); this.SetAsCompleted(new OperationFailureException("AcdConferenceServicesAnchor failed creating a conference", ivoex), false); } }, conferenceManagement); } catch (InvalidOperationException ivoex) { _anchor._logger.Log("AcdConferenceServicesAnchor failed to create a conference", ivoex); _anchor.BeginShutDown(sar => { AcdConferenceServicesAnchor anchor = sar.AsyncState as AcdConferenceServicesAnchor; anchor.EndShutDown(sar); }, _anchor); this.SetAsCompleted(new OperationFailureException("AcdConferenceServicesAnchor failed to create a conference", ivoex), false); } } else { _anchor.RegisterForEvents(); ConferenceJoinOptions options = new ConferenceJoinOptions(); options.JoinMode = JoinMode.TrustedParticipant; try { _anchor._conversation.ConferenceSession.BeginJoin(_anchor._conferenceUri, options, jar => { Conversation conv = jar.AsyncState as Conversation; try { conv.ConferenceSession.EndJoin(jar); _anchor.UpdateState(ConferenceServicesAnchorState.Established); this.SetAsCompleted(null, false); } catch (RealTimeException rtex) { if (null != _anchor) { _anchor._logger.Log("AcdConferenceServicesAnchor failed to create a conference", rtex); } _anchor.BeginShutDown(sar => { AcdConferenceServicesAnchor anchor = sar.AsyncState as AcdConferenceServicesAnchor; anchor.EndShutDown(sar); }, _anchor); this.SetAsCompleted(rtex, false); } }, _anchor._conversation); } catch (InvalidOperationException ivoex) { _anchor._logger.Log("AcdConferenceServicesAnchor failed to create a conference", ivoex); _anchor.BeginShutDown(sar => { AcdConferenceServicesAnchor anchor = sar.AsyncState as AcdConferenceServicesAnchor; anchor.EndShutDown(sar); }, _anchor); this.SetAsCompleted(new OperationFailureException("AcdConferenceServicesAnchor failed to create a conference", ivoex), false); } } }