/// <summary> /// Creates the P2PEndpoint for sending the Notify. A P2P endpoint enjoys /// auto-provisioning of the necessary application endpoint settings /// if it is obtained from an established ApplicationEndpoint created with /// ProvisionedApplicationPlatformSettings. /// </summary> void CreateP2PEndpoint() { Console.WriteLine("Creating P2P Endpoint...for {0}", _appID); try { if (!string.IsNullOrEmpty(_appID)) { Console.WriteLine("Creating CollaborationPlatform for the provisioned application with " + "ID \'{0}\' using ProvisionedApplicationPlatformSettings.", _appID); ProvisionedApplicationPlatformSettings settings = new ProvisionedApplicationPlatformSettings("UCMASampleApp", _appID); _collabPlatform = new CollaborationPlatform(settings); // Receive applicationEndpoint settings via auto-provisioning _collabPlatform.RegisterForApplicationEndpointSettings(ApplicationEndpointSettingsDiscovered); _collabPlatform.EndStartup(_collabPlatform.BeginStartup(null, null)); Console.WriteLine("platform started."); } else { Console.WriteLine("Error: Application ID not provided."); } } catch (Exception iOpEx) { Console.WriteLine(iOpEx.ToString()); } }
/// <summary> /// Retrieves the application configuration and begins running the /// sample. /// </summary> void Run() { _appID = null; try { // Attempt to retrieve the application ID of the provisioned // application from the config file. _appID = System.Configuration.ConfigurationManager.AppSettings["ApplicationID"]; if (string.IsNullOrEmpty(_appID)) { // The application ID wasn't retrieved from the config file // so prompt for the application ID for the application that // has been provisioned. string prompt = "Please enter the unique ID of the application that is provisioned in " + "the topology => "; _appID = UCMASampleHelper.PromptUser(prompt, null); } if (!string.IsNullOrEmpty(_appID)) { Console.WriteLine("Creating CollaborationPlatform for the provisioned application with " + "ID \'{0}\' using ProvisionedApplicationPlatformSettings.", _appID); ProvisionedApplicationPlatformSettings settings = new ProvisionedApplicationPlatformSettings("UCMASampleApp", _appID); _collabPlatform = new CollaborationPlatform(settings); // Wire up a handler for the // ApplicationEndpointOwnerDiscovered event. _collabPlatform.RegisterForApplicationEndpointSettings( this.Platform_ApplicationEndpointOwnerDiscovered); // Initialize and startup the platform. _collabPlatform.BeginStartup(EndPlatformStartup, _collabPlatform); } else { Console.WriteLine("No application ID was specified by the user."); } UCMASampleHelper.PauseBeforeContinuing("Press ENTER to shutdown and exit."); } catch (InvalidOperationException iOpEx) { // Invalid Operation Exception may be thrown if the data // provided to the BeginXXX methods was // invalid/malformed. // TODO (Left to the reader): Write actual handling code for the // occurrence. Console.WriteLine("Invalid Operation Exception: " + iOpEx.ToString()); } finally { // Terminate the platform which would in turn terminate any // endpoints. Console.WriteLine("Shutting down the platform."); ShutdownPlatform(); } }
public async Task Start() { try { Console.WriteLine("Starting Collaboration Platform"); ProvisionedApplicationPlatformSettings settings = new ProvisionedApplicationPlatformSettings(_appUserAgent, _appID); _collabPlatform = new CollaborationPlatform(settings); _collabPlatform.RegisterForApplicationEndpointSettings(OnNewApplicationEndpointDiscovered); await _collabPlatform.StartupAsync(); Console.WriteLine("Platform Started"); } catch (Exception ex) { Console.WriteLine("Error establishing collaboration platform: {0}", ex.ToString()); } }
void Run() { _AppID = System.Configuration.ConfigurationManager.AppSettings["ApplicationID"]; ProvisionedApplicationPlatformSettings settings = new ProvisionedApplicationPlatformSettings("My UCMA Application", _AppID); _CollabPlatform = new CollaborationPlatform(settings); _CollabPlatform.RegisterForApplicationEndpointSettings(Platform_ApplicationEndpointOwnerDiscovered); Console.WriteLine("Starting collaboration platform"); _CollabPlatform.BeginStartup(PlatformStartupComplete, _CollabPlatform); //PauseBeforeContinuing("Press enter to shutdown and exit"); Console.WriteLine("Shutting down the platform."); //ShutdownPlatform(); }
public static void Main(string[] args) { try { string appId = ConfigurationManager.AppSettings["ApplicationID"]; Console.WriteLine("Creating CollaborationPlatform for the provisioned application with " + "ID \'{0}\' using ProvisionedApplicationPlatformSettings.", appId); ProvisionedApplicationPlatformSettings settings = new ProvisionedApplicationPlatformSettings("UCMASampleApp", appId); settings.DefaultAudioVideoProviderEnabled = true; _collabPlatform = new CollaborationPlatform(settings); _collabPlatform.InstantMessagingSettings.SupportedFormats = InstantMessagingFormat.All; // Wire up a handler for the // ApplicationEndpointOwnerDiscovered event. _collabPlatform.RegisterForApplicationEndpointSettings( Platform_ApplicationEndpointOwnerDiscovered); // Initalize and startup the platform. _collabPlatform.BeginStartup(EndPlatformStartup, _collabPlatform); Console.WriteLine("Please hit Esc key to end the sample."); ConsoleKeyInfo info = Console.ReadKey(); while (info.Key != ConsoleKey.Escape) { info = Console.ReadKey(); } } catch (InvalidOperationException iOpEx) { Console.WriteLine("Invalid Operation Exception: " + iOpEx.ToString()); } finally { Console.WriteLine("Shutting down the platform."); ShutdownPlatform(); } }
public void Start() { // Get the application ID from App.config. string applicationUserAgent = "maximillian"; string applicationId = ConfigurationManager.AppSettings["applicationId"]; // Create a settings object. ProvisionedApplicationPlatformSettings settings = new ProvisionedApplicationPlatformSettings(applicationUserAgent, applicationId); // Create a new collaboration platform with the settings. _collaborationPlatform = new CollaborationPlatform(settings); _collaborationPlatform.RegisterForApplicationEndpointSettings(OnApplicationEndpointSettingsDiscovered); _logger.Log("Starting collaboration platform..."); // Start the platform as an asynchronous operation. _collaborationPlatform.BeginStartup(OnPlatformStartupCompleted, null); }
//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); }); }
/// <summary> /// Returns an application endpoint that is provisioned on a platform /// as specified by the ApplicationID which could be provided by config /// file or be prompted to the user; if the platform discovers multiple /// application endpoints the first one discovered and established will be /// returned. If no application endpoints are discovered this method /// returns null. /// </summary> /// <returns></returns> public ApplicationEndpoint CreateAutoProvisionedApplicationEndpoint() { _applicationId = null; try { // Attempt to retrieve the application ID of the provisioned // application from the config file. _applicationId = System.Configuration.ConfigurationManager.AppSettings["ApplicationID"]; if (string.IsNullOrEmpty(_applicationId)) { // The application ID wasn't retrieved from the config file // so prompt for the application ID for the application that // has been provisioned. string prompt = "Please enter the unique ID of the application that is provisioned in " + "the topology => "; _applicationId = UCMASampleHelper.PromptUser(prompt, null); } if (!string.IsNullOrEmpty(_applicationId)) { UCMASampleHelper.WriteLine("Creating CollaborationPlatform for the provisioned application" + " with ID \'" + _applicationId + "\' using ProvisionedApplicationPlatformSettings."); ProvisionedApplicationPlatformSettings settings = new ProvisionedApplicationPlatformSettings("UCMASampleApp", _applicationId); // Reuse platform instance so that all endpoints share the // same platform. if (_collabPlatform == null) { // Initalize and startup the platform. _collabPlatform = new CollaborationPlatform(settings); // Wire up a handler for the // ApplicationEndpointOwnerDiscovered event. _collabPlatform.RegisterForApplicationEndpointSettings( this.Platform_ApplicationEndpointOwnerDiscovered); // Initalize and startup the platform. _collabPlatform.BeginStartup(EndPlatformStartup, _collabPlatform); if (_endpointInitCompletedEvent.WaitOne()) { UCMASampleHelper.WriteLine("Found an application EP the Owner Uri is: " + _applicationEndpoint.OwnerUri); } else { Console.WriteLine("Application endpoint was not established within the given time," + " ending Sample."); UCMASampleHelper.FinishSample(); } } else { Console.WriteLine("Collaboration platform already exists, ending Sample."); UCMASampleHelper.FinishSample(); } } else { Console.WriteLine("No application ID was specified by the user. Unable to create an" + " ApplicationEndpoint to use in the sample."); UCMASampleHelper.FinishSample(); } return(_applicationEndpoint); } catch (InvalidOperationException iOpEx) { // Invalid Operation Exception may be thrown if the data provided // to the BeginStartUp is called when the platform has already been // started or terminated. // TODO (Left to the reader): Error handling code. UCMASampleHelper.WriteException(iOpEx); return(_applicationEndpoint); } }
/// <summary> /// Method to start platform and endpoint initialization. /// </summary> public void Start() { if (m_disposed) { throw new ObjectDisposedException("Please restart"); } string applicationId = Configuration.ApplicationId; if (!String.IsNullOrEmpty(applicationId)) { ProvisionedApplicationPlatformSettings settings = new ProvisionedApplicationPlatformSettings(UcmaHelper.ApplicationName, applicationId); //Create the platform. m_collabPlatform = new CollaborationPlatform(settings); //Populate im flow template. InstantMessagingFlowTemplate imFlowTemplate = new InstantMessagingFlowTemplate(); imFlowTemplate.ComposingTimeoutValue = 10; //seconds imFlowTemplate.SupportedFormats = InstantMessagingFormat.PlainText | InstantMessagingFormat.HtmlText; imFlowTemplate.MessageConsumptionMode = InstantMessageConsumptionMode.ProxiedToRemoteEntity; imFlowTemplate.ToastFormatSupport = CapabilitySupport.UnSupported; m_collabPlatform.InstantMessagingSettings = imFlowTemplate; // Wire up a handler for the ApplicationEndpointOwnerDiscovered event. m_collabPlatform.RegisterForApplicationEndpointSettings(this.Platform_ApplicationEndpointOwnerDiscovered); bool needCleanup = true; try { m_collabPlatform.BeginStartup(this.PlatformStartupCompleted, m_collabPlatform); needCleanup = false; } catch (InvalidOperationException ioe) { Helper.Logger.Error("Exception caught during startup {0}", EventLogger.ToString(ioe)); } finally { if (needCleanup) { this.Cleanup(); } } //Wait for all operations to complete. var allDone = m_allDone; if (allDone != null) { bool succeeded = m_allDone.WaitOne(UcmaHelper.MaxTimeoutInMillis, false /*exitContext*/); if (!succeeded) { Helper.Logger.Error("Initialization did not complete in expected time."); } } } else { Helper.Logger.Error("Invalid application id. Please provide a valid value for application id in the web.config file."); } }