private void ShutdownCollaborationPlatform(AsyncTask task, object state) { CollaborationPlatform platform = m_platform; if (platform == null) { task.Complete(null); return; } task.DoOneStep( delegate() { m_platform.BeginShutdown( delegate(IAsyncResult ar) { task.DoFinalStep( delegate() { m_platform.EndShutdown(ar); this.Logger.Log(Logger.LogLevel.Info, "Platform shutdown completed."); }); }, null); }); }
private void ShutdownPresenceView(AsyncTask task, object state) { RemotePresenceView presenceView = m_remotePresenceView; if (presenceView == null) { task.Complete(null); return; } m_remotePresenceView.PresenceNotificationReceived -= this.PresenceView_NotificationReceived; task.DoOneStep( delegate() { presenceView.BeginTerminate( delegate(IAsyncResult ar) { task.DoFinalStep( delegate() { presenceView.EndTerminate(ar); }); }, null); }); }
private void ShutdownUserEndpoint(AsyncTask task, object state) { UserEndpoint userEndpoint = state as UserEndpoint; if (userEndpoint == null) { task.Complete(null); return; } task.DoOneStep( delegate() { Logger.Log(Logger.LogLevel.Info, "Terminating UserEndpoint." + userEndpoint.OwnerUri); userEndpoint.BeginTerminate( delegate(IAsyncResult ar) { task.DoFinalStep( delegate() { userEndpoint.EndTerminate(ar); Logger.Log(Logger.LogLevel.Info, "Terminated UserEndpoint." + userEndpoint.OwnerUri); }); }, null); }); }
private void StartupEndpoint(AsyncTask task, object state) { task.DoOneStep( delegate() { m_endpoint = new ApplicationEndpoint(m_parent.Platform, m_settings); m_endpoint.RegisterForIncomingCall <AudioVideoCall>(this.ReceiveIncomingAvCall); m_endpoint.RegisterForIncomingCall <InstantMessagingCall>(this.ReceiveIncomingIMCall); m_endpoint.LocalOwnerPresence.SubscriberNotificationReceived += SubscriberNotificationReceived; m_endpoint.StateChanged += this.EndpointStateChanged; Logger.Log(Logger.LogLevel.Info, "Starting Application Endpoint."); m_endpoint.BeginEstablish( delegate(IAsyncResult ar) { task.DoOneStep( delegate() { m_endpoint.EndEstablish(ar); Logger.Log(Logger.LogLevel.Info, "Started Application Endpoint. Tel #:" + m_endpoint.OwnerPhoneUri ?? "null"); m_endpoint.LocalOwnerPresence.BeginSubscribe( delegate(IAsyncResult ar2) { task.DoFinalStep( delegate() { m_endpoint.LocalOwnerPresence.EndSubscribe(ar2); }); }, null); }); }, null); }); }
private void ShutdownReverseLookup(AsyncTask task, object state) { ReverseNumberLookup rnl = m_reverseNumberLookup; if (rnl == null) { task.Complete(null); return; } task.DoOneStep( delegate() { this.Logger.Log(Logger.LogLevel.Info, "Shuttong down Reverse Number Lookup."); rnl.BeginShutdown( delegate(IAsyncResult ar) { task.DoFinalStep( delegate() { rnl.EndShutdown(ar); this.Logger.Log(Logger.LogLevel.Info, "Reverse Number Lookup shutdown."); }); }, null); }); }
private void ShutdownContactSubscription(AsyncTask task, object state) { if (m_contactGroupServices.CurrentState != CollaborationSubscriptionState.Subscribed) { task.Complete(null); return; } m_contactGroupServices.NotificationReceived -= this.ContactGroupServices_NotificationReceived; task.DoOneStep( delegate() { Logger.Log(Logger.LogLevel.Info, "Starting contact unsubscription."); m_contactGroupServices.BeginUnsubscribe( delegate(IAsyncResult ar) { task.DoFinalStep( delegate() { m_contactGroupServices.EndUnsubscribe(ar); Logger.Log(Logger.LogLevel.Info, "Started contact unsubscription."); }); }, null); }); }
private void EstablishServiceChannel(AsyncTask task, object state) { task.DoOneStep( delegate() { m_serviceChannelCall = new AudioVideoCall(m_serviceHub.Conversation); var options = new AudioVideoCallEstablishOptions(); // Ee need to use generated user identity for the call as this is hidden participant // of the conference for service purpose. options.UseGeneratedIdentityForTrustedConference = !this.IsPrimaryServiceChannel; if (!this.IsPrimaryServiceChannel) { this.RegisterServiceCallHandlers(); // Service call does not need to be in default mix of the conference. The purpose is to service a specific target user in the conference. options.AudioVideoMcuDialInOptions.RemoveFromDefaultRouting = true; } m_serviceChannelCall.BeginEstablish( options, delegate(IAsyncResult ar) { task.DoFinalStep( delegate() { m_serviceChannelCall.EndEstablish(ar); }); }, null); }); }
/// <summary> /// Setup mode of interaction for the customer endpoint. This can be done only after the customer endpoint is seen. /// </summary> /// <param name="task">The task instance for this operation.</param> /// <remarks>To add announce but remove listening (or vice versa), two operations would be needed.</remarks> public void UpdateInteractiveMode(AsyncTask task, object state) { ArgumentTuple args = (ArgumentTuple)state; task.DoOneStep( delegate() { InteractionMode interactiveMode = InteractionMode.None; bool isAdd = false; isAdd = (bool)args.One; interactiveMode = (InteractionMode)args.Two; // Integer var outgoingRoutes = new List <OutgoingAudioRoute>(); var incomingRoutes = new List <IncomingAudioRoute>(); InteractionMode announce = InteractionMode.AnnounceSpeech | InteractionMode.AnnounceSpeechAndDtmf; InteractionMode listen = InteractionMode.ListenSpeech | InteractionMode.ListenSpeechAndDtmf; if ((interactiveMode & announce) != 0) { OutgoingAudioRoute outRoute = new OutgoingAudioRoute(this.TargetUriEndpoint); outRoute.IsDtmfEnabled = (interactiveMode & InteractionMode.AnnounceSpeechAndDtmf) != 0; outRoute.Operation = isAdd ? RouteUpdateOperation.Add : RouteUpdateOperation.Remove; outgoingRoutes.Add(outRoute); } if ((interactiveMode & listen) != 0) { IncomingAudioRoute inRoute = new IncomingAudioRoute(this.TargetUriEndpoint); inRoute.IsDtmfEnabled = (interactiveMode & InteractionMode.ListenSpeechAndDtmf) != 0; inRoute.Operation = isAdd ? RouteUpdateOperation.Add : RouteUpdateOperation.Remove; incomingRoutes.Add(inRoute); } m_serviceChannelCall.AudioVideoMcuRouting.BeginUpdateAudioRoutes( outgoingRoutes, incomingRoutes, delegate(IAsyncResult ar) { task.DoFinalStep( delegate() { m_serviceChannelCall.AudioVideoMcuRouting.EndUpdateAudioRoutes(ar); }); }, null); }); }
private void StartupUserEndpoint(AsyncTask task, object state) { UserEndpoint userEndpoint = state as UserEndpoint; task.DoOneStep( delegate() { if (userEndpoint == null) { task.Complete(new InvalidOperationException("UserEndpoint is needed to establish.")); return; } else if (userEndpoint.State == LocalEndpointState.Established) { task.Complete(null); // Already established. } else if (userEndpoint.State == LocalEndpointState.Idle) { Logger.Log(Logger.LogLevel.Info, "Establishing UserEndpoint." + userEndpoint.OwnerUri); userEndpoint.BeginEstablish( delegate(IAsyncResult ar) { task.DoOneStep( delegate() { userEndpoint.EndEstablish(ar); Logger.Log(Logger.LogLevel.Info, "Established UserEndpoint." + userEndpoint.OwnerUri); userEndpoint.LocalOwnerPresence.BeginSubscribe( delegate(IAsyncResult ar2) { task.DoFinalStep( delegate() { userEndpoint.LocalOwnerPresence.EndSubscribe(ar2); }); }, null); }); }, null); } else { task.Complete(new InvalidOperationException("UserEndpoint should be in Idle state to establish.")); } }); }
protected void StartupJoinConference(AsyncTask task, object state) { task.DoOneStep( delegate() { Conference conference = null; AsyncTaskResult conferenceActionResult = task.PreviousActionResult; // Normally, the previous task should be the one that scheduled the conference. But, play safe to allow other actions in between. while (conferenceActionResult != null) { ConferenceActionResult conferenceResult = conferenceActionResult as ConferenceActionResult; if (conferenceResult != null) { conference = conferenceResult.Conference; break; } conferenceActionResult = conferenceActionResult.PreviousActionResult; } if (conference == null) { task.Complete(new InvalidOperationException("StartupConferenceJoin: Conference must be scheduled before conference join operation.")); return; } ConferenceJoinOptions options = new ConferenceJoinOptions(); options.JoinMode = JoinMode.TrustedParticipant; m_tcuConversation.ConferenceSession.BeginJoin( conference.ConferenceUri, options, delegate(IAsyncResult ar) { task.DoFinalStep( delegate() { m_tcuConversation.ConferenceSession.EndJoin(ar); this.Logger.Log(Logger.LogLevel.Verbose, String.Format("ServiceHub {0} joined TCU conference {1}.", this.CustomerSession.Customer.UserUri, m_tcuConversation.ConferenceSession.ConferenceUri)); }); }, null); }); }
private void StartupCallbackManager(AsyncTask task, object state) { task.DoOneStep( delegate() { m_callbackManager = new CallbackManager(this); //Logger.Log(Logger.LogLevel.Info, "Starting Callback Manager."); m_callbackManager.BeginStartup( delegate(IAsyncResult ar) { task.DoFinalStep( delegate() { m_callbackManager.EndStartup(ar); //Logger.Log(Logger.LogLevel.Info, "Started Callback Manager."); }); }, null); }); }
private void ShutdownCustomerSession(AsyncTask task, object state) { CustomerSession customerSession = (CustomerSession)state; task.DoOneStep( delegate() { customerSession.BeginShutdown( delegate(IAsyncResult ar) { task.DoFinalStep( delegate() { customerSession.EndShutdown(ar); //this.Logger.Log(Logger.LogLevel.Info, String.Format("Customer session {0} shutdown.", customerSession.Customer.UserUri)); }); }, null); }); }
private void ShutdownFrontEnd(AsyncTask task, object state) { task.DoOneStep( delegate() { AppFrontEnd frontEnd = (AppFrontEnd)state; this.Logger.Log(Logger.LogLevel.Info, String.Format("Sutting down FrontEnd {0}.", frontEnd.Endpoint.OwnerUri)); frontEnd.BeginShutdown( delegate(IAsyncResult ar) { task.DoFinalStep( delegate() { frontEnd.EndShutdown(ar); this.Logger.Log(Logger.LogLevel.Info, String.Format("FrontEnd {0} shutdown.", frontEnd.Endpoint.OwnerUri)); }); }, null); }); }
private void StartupReverseLookup(AsyncTask task, object state) { task.DoOneStep( delegate() { m_reverseNumberLookup = ReverseNumberLookup.GetLookupInstance(this); //this.Logger.Log(Logger.LogLevel.Info, "Starting Reverse Number Lookup"); m_reverseNumberLookup.BeginStartup( delegate(IAsyncResult ar) { task.DoFinalStep( delegate() { m_reverseNumberLookup.EndStartup(ar); //this.Logger.Log(Logger.LogLevel.Info, "Reverse Number Lookup started"); }); }, null); }); }
private void StartupMusicProvider(AsyncTask task, object state) { task.DoOneStep( delegate() { var mohFileConfig = ApplicationConfiguration.GetMusicOnHoldConfiguration(); m_mohProvider = new MusicProvider(this.AppPlatform, mohFileConfig.FilePath); //Logger.Log(Logger.LogLevel.Info, "Starting Music Provider."); m_mohProvider.BeginStartup( delegate(IAsyncResult ar) { task.DoFinalStep( delegate() { m_mohProvider.EndStartup(ar); //Logger.Log(Logger.LogLevel.Info, "Started Music Provider."); }); }, null); }); }
private void ShutdownPresenceView(AsyncTask task, object state) { task.DoOneStep( delegate() { CallbackRequest callbackRequest = (CallbackRequest)state; var presenceView = callbackRequest.PresenceView; presenceView.PresenceNotificationReceived -= this.PresenceView_NotificationReceived; presenceView.SubscriptionStateChanged -= this.PresenceView_SubscriptionStateChanged; presenceView.BeginTerminate( delegate(IAsyncResult ar) { task.DoFinalStep( delegate() { presenceView.EndTerminate(ar); }); }, null); }); }
private void StartupPrimaryChannel(AsyncTask task, object state) { task.DoOneStep( delegate() { m_primaryTracker = new RosterTrackingService(this.CustomerSession.AppFrontEnd, new TimeSpan(0, 0, 1)); m_primaryTracker.TargetUri = this.CustomerSession.AppFrontEnd.Endpoint.OwnerUri; m_primaryChannel = new ServiceChannel(this, m_customerTracker); m_primaryChannel.IsPrimaryServiceChannel = true; m_primaryChannel.BeginStartup( delegate(IAsyncResult ar) { task.DoFinalStep( delegate() { m_primaryChannel.EndStartup(ar); //Logger.Log(Logger.LogLevel.Info, "Started primary service channel(TCU)."); }); }, null); }); }
private void StartupPresenceView(AsyncTask task, object state) { task.DoFinalStep( delegate() { CallbackRequest callbackRequest = (CallbackRequest)state; var viewSettings = new RemotePresenceViewSettings(); viewSettings.SubscriptionMode = RemotePresenceViewSubscriptionMode.Persistent; var presenceView = new RemotePresenceView(callbackRequest.CutomerEndpoint, viewSettings); presenceView.ApplicationContext = callbackRequest; var target = new RemotePresentitySubscriptionTarget(callbackRequest.TargetUri); presenceView.PresenceNotificationReceived += this.PresenceView_NotificationReceived; presenceView.SubscriptionStateChanged += this.PresenceView_SubscriptionStateChanged; callbackRequest.PresenceView = presenceView; presenceView.StartSubscribingToPresentities( new RemotePresentitySubscriptionTarget[] { target }); }); }
//Commented the functions used to start and stop workflow runtime service as workflows are not to be used /* * private void StartWorkflowRuntime(AsyncTask task, object state) * { * m_workflowRuntime = new WorkflowRuntime(); * m_workflowRuntime.AddService(new CommunicationsWorkflowRuntimeService()); * m_workflowRuntime.AddService(new TrackingDataWorkflowRuntimeService()); * * task.DoFinalStep( * delegate() * { * m_workflowRuntime.StartRuntime(); * this.Logger.Log(Logger.LogLevel.Info, "Workflow started."); * }); * } * * private void ShutdownWorkflowRuntime(AsyncTask task, object state) * { * if (m_workflowRuntime == null) * { * task.Complete(null); * return; * } * task.DoFinalStep( * delegate() * { * m_workflowRuntime.StopRuntime(); * this.Logger.Log(Logger.LogLevel.Info, "Workflow shutdown."); * }); * } */ private void StartupPlatform(AsyncTask task, object state) { task.DoOneStep( delegate() { var settings = new ProvisionedApplicationPlatformSettings(m_userAgent, m_applicationId); m_platform = new CollaborationPlatform(settings); m_platform.RegisterForApplicationEndpointSettings(this.ApplicationEndpointOwnerDiscovered); //this.Logger.Log(Logger.LogLevel.Info, "Starting the Collaboration Platform."); m_platform.BeginStartup( delegate(IAsyncResult ar) { task.DoFinalStep( delegate() { m_platform.EndStartup(ar); //this.Logger.Log(Logger.LogLevel.Info, "Collaboration Platform started."); }); }, null); }); }
private void StartupScheduleConference(AsyncTask task, object state) { task.DoOneStep( delegate() { m_tcuConversation = new Conversation(m_parent.AppFrontEnd.Endpoint); m_tcuConversation.ApplicationContext = this; m_avmcuSession = m_tcuConversation.ConferenceSession.AudioVideoMcuSession; m_avmcuSession.ParticipantEndpointAttendanceChanged += this.ParticipantEndpointAttendanceChanged; ConferenceServices conferenceManagement = m_parent.AppFrontEnd.Endpoint.ConferenceServices; //Create a conference to anchor the incoming customer call ConferenceScheduleInformation conferenceScheduleInfo = new ConferenceScheduleInformation(); conferenceScheduleInfo.AutomaticLeaderAssignment = AutomaticLeaderAssignment.SameEnterprise; conferenceScheduleInfo.LobbyBypass = LobbyBypass.EnabledForGatewayParticipants; conferenceScheduleInfo.AccessLevel = ConferenceAccessLevel.SameEnterprise; conferenceScheduleInfo.PhoneAccessEnabled = false; conferenceScheduleInfo.AttendanceAnnouncementsStatus = AttendanceAnnouncementsStatus.Disabled; conferenceScheduleInfo.Mcus.Add(new ConferenceMcuInformation(McuType.AudioVideo)); //schedule the conference conferenceManagement.BeginScheduleConference(conferenceScheduleInfo, delegate(IAsyncResult sch) { task.DoFinalStep( delegate() { Conference conference; conference = conferenceManagement.EndScheduleConference(sch); task.TaskResult = new ConferenceActionResult(conference); // Store so that next task can get it. }); }, null); }); }
private void ShutdownCallbackManager(AsyncTask task, object state) { if (m_callbackManager == null) { task.Complete(null); return; } task.DoOneStep( delegate() { CallbackManager callbackManager = m_callbackManager; callbackManager.BeginShutdown( delegate(IAsyncResult ar) { task.DoFinalStep( delegate() { callbackManager.EndShutdown(ar); this.Logger.Log(Logger.LogLevel.Verbose, "Callback Manager shutdown."); }); }, null); }); }
private void ShutdownMusicProvider(AsyncTask task, object state) { if (m_mohProvider == null) { task.Complete(null); return; } task.DoOneStep( delegate() { MusicProvider musicProvider = m_mohProvider; musicProvider.BeginShutdown( delegate(IAsyncResult ar) { task.DoFinalStep( delegate() { musicProvider.EndShutdown(ar); this.Logger.Log(Logger.LogLevel.Verbose, "Music provider shutdown."); }); }, null); }); }
private void ShutdownEndpoint(AsyncTask task, object state) { if (m_endpoint == null) { task.Complete(null); return; } task.DoOneStep( delegate() { Logger.Log(Logger.LogLevel.Info, "Terminating Application Endpoint."); m_endpoint.BeginTerminate( delegate(IAsyncResult ar) { task.DoFinalStep( delegate() { m_endpoint.EndTerminate(ar); Logger.Log(Logger.LogLevel.Info, "Terminated Application Endpoint."); }); }, null); }); }