/// <summary>
        /// Event handler to receive auto-provisioned ApplicationEndpointSettings for
        /// a given application Id. Auto-provisioned ApplicationEndpointSettings contains
        /// the correct proxy server and proxy port, as well as other configurational
        /// information required to establish a connection between the endpoint and the
        /// server.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        static void ApplicationEndpointSettingsDiscovered(object sender,
                                                          ApplicationEndpointSettingsDiscoveredEventArgs e)
        {
            Console.WriteLine("ApplicationEndpointOwnerDiscovered event was raised.");
            Console.WriteLine("provisioned application ID = \'{0}\' ", _appID);
            Console.WriteLine("Owner display name is: " + e.ApplicationEndpointSettings.OwnerDisplayName);
            Console.WriteLine("Owner URI is: " + e.ApplicationEndpointSettings.OwnerUri);
            Console.WriteLine("ProxyHost: " + e.ApplicationEndpointSettings.ProxyHost);
            Console.WriteLine("ProxyPort: " + e.ApplicationEndpointSettings.ProxyPort);

            try
            {
                ApplicationEndpointSettings settings = e.ApplicationEndpointSettings;
                _superEndpoint = new ApplicationEndpoint(_collabPlatform, settings);

                // Establish the endpoint.
                _superEndpoint.EndEstablish(_superEndpoint.BeginEstablish(null, null));

                Console.WriteLine("ApplicationEndpoint state={0}", _superEndpoint.State.ToString());
                _superP2PEndpoint = (SipPeerToPeerEndpoint)_superEndpoint.InnerEndpoint;
            }
            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): Error handling code.
                Console.WriteLine("Invalid Operation Exception: " + iOpEx.ToString());
            }
        }
Exemple #2
0
        // Registered event handler for the ApplicationEndpointOwnerDiscovered event on the
        // CollaborationPlatform for the provisioned application.
        private void Platform_ApplicationEndpointOwnerDiscovered(object sender,
                                                                 ApplicationEndpointSettingsDiscoveredEventArgs e)
        {
            Helper.Logger.Info("ApplicationEndpointOwnerDiscovered event was raised during startup of the "
                               + "CollaborationPlatform.");

            ApplicationEndpointSettings settings = e.ApplicationEndpointSettings;

            settings.UseRegistration = false;

            m_applicationEndpoint = new ApplicationEndpoint(m_collabPlatform, settings);

            bool epBeginEstablishFailed = true;

            try
            {
                this.RegisterEndpointEventHandlers(m_applicationEndpoint);
                m_applicationEndpoint.BeginEstablish(this.EndpointEstablishCompleted, m_applicationEndpoint);
                epBeginEstablishFailed = false;
            }
            catch (InvalidOperationException ioe)
            {
                Helper.Logger.Error("Endpoint establishment operation threw an exception {0}", EventLogger.ToString(ioe));
            }
            finally
            {
                if (epBeginEstablishFailed)
                {
                    this.Cleanup();
                }
            }
        }
Exemple #3
0
        // Registered event handler for the ApplicationEndpointOwnerDiscovered
        // event on the CollaborationPlatform for the provisioned application.
        private void Platform_ApplicationEndpointOwnerDiscovered(object sender,
                                                                 ApplicationEndpointSettingsDiscoveredEventArgs e)
        {
            Console.WriteLine("ApplicationEndpointOwnerDiscovered event was raised during startup of the "
                              + "CollaborationPlatform for the provisioned application with ID \'{0}\'.");

            ApplicationEndpointSettings settings = e.ApplicationEndpointSettings;

            settings.SupportedMimePartContentTypes = new ContentType[] { new ContentType("text/plain") };

            //Set the endpoint presence to appear as always online
            InitializePublishAlwaysOnlineSettings(settings);

            Console.WriteLine("Initializing the ApplicationEndpoint that corresponds to the provisioned "
                              + "application with ID \'{0}\'.", _appID);

            // Initialize the endpoint using the settings retrieved above.
            _appEndpoint = new ApplicationEndpoint(_collabPlatform, settings);
            // Wire up the StateChanged event.
            _appEndpoint.StateChanged += this.Endpoint_StateChanged;
            try
            {
                // Establish the endpoint.
                _appEndpoint.BeginEstablish(EndEndpointEstablish, _appEndpoint);
            }
            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());
            }
        }
Exemple #4
0
 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);
     });
 }
Exemple #5
0
        private void Platform_ApplicationEndpointOwnerDiscovered(object sender, ApplicationEndpointSettingsDiscoveredEventArgs e)
        {
            Console.WriteLine("Contact discovered: {0}", e.ApplicationEndpointSettings.OwnerUri);
            
            var settings = e.ApplicationEndpointSettings;
            
            settings.AutomaticPresencePublicationEnabled = true;
            settings.Presence.PresentityType = "automaton";
            settings.Presence.Description = "Toujours disponible !";

            _applicationEndpoint = new ApplicationEndpoint(_CollabPlatform, settings);
            Console.WriteLine("Establishing the endopint");
            _applicationEndpoint.BeginEstablish(EndpointEstablishCompleted, null);
        }
            private static ApplicationEndpoint CreateEndPoint(ServerPlatformSettings settings)
            {
                CollaborationPlatform collaborationPlatform = new CollaborationPlatform(settings);

                collaborationPlatform.EndStartup(collaborationPlatform.BeginStartup(null, null));
                ApplicationEndpoint result;

                try
                {
                    ApplicationEndpoint applicationEndpoint = new ApplicationEndpoint(collaborationPlatform, new ApplicationEndpointSettings(BaseUMconnectivityTester.SipPlatformConnectionManager.OwnerUri));
                    applicationEndpoint.EndEstablish(applicationEndpoint.BeginEstablish(null, null));
                    result = applicationEndpoint;
                }
                catch (Exception)
                {
                    collaborationPlatform.EndShutdown(collaborationPlatform.BeginShutdown(null, null));
                    throw;
                }
                return(result);
            }
Exemple #7
0
        // Registered event handler for the ApplicationEndpointOwnerDiscovered event on the
        // CollaborationPlatform for the provisioned application.
        static void Platform_ApplicationEndpointOwnerDiscovered(object sender,
                                                                ApplicationEndpointSettingsDiscoveredEventArgs e)
        {
            Console.WriteLine("ApplicationEndpointOwnerDiscovered event was raised during startup of the CollaborationPlatform.");
            Console.WriteLine("The ApplicationEndpointOwnerConfiguration that corresponds to the provisioned application are: ");
            Console.WriteLine("Owner display name is: " + e.ApplicationEndpointSettings.OwnerDisplayName);
            Console.WriteLine("Owner URI is: " + e.ApplicationEndpointSettings.OwnerUri);
            Console.WriteLine("Now retrieving the ApplicationEndpointSettings from the ApplicationEndpointSettingsDiscoveredEventArgs.");

            ApplicationEndpointSettings settings = e.ApplicationEndpointSettings;

            settings.AutomaticPresencePublicationEnabled = true;
            settings.SupportedMimePartContentTypes       = new ContentType[] { new ContentType("text/plain") };
            settings.Presence.Description = "AlwaysOnlineBot";

            PreferredServiceCapabilities capabilities = settings.Presence.PreferredServiceCapabilities;

            capabilities.ApplicationSharingSupport = CapabilitySupport.Supported;
            capabilities.AudioSupport            = CapabilitySupport.Supported;
            capabilities.InstantMessagingSupport = CapabilitySupport.Supported;
            capabilities.VideoSupport            = CapabilitySupport.Supported;

            Console.WriteLine("Initializing the ApplicationEndpoint that corresponds to the provisioned application.");

            // Initalize the endpoint using the settings retrieved above.
            _appEndpoint = new ApplicationEndpoint(_collabPlatform, settings);
            // Wire up the StateChanged event.
            _appEndpoint.StateChanged += Endpoint_StateChanged;
            // Wire up the ApplicationEndpointOwnerPropertiesChanged event.
            _appEndpoint.OwnerPropertiesChanged += Endpoint_ApplicationEndpointOwnerPropertiesChanged;

            try
            {
                // Establish the endpoint.
                _appEndpoint.BeginEstablish(EndEndpointEstablish, _appEndpoint);
            }
            catch (InvalidOperationException iOpEx)
            {
                Console.WriteLine("Invalid Operation Exception: " + iOpEx.ToString());
            }
        }
Exemple #8
0
        // Registered event handler for the ApplicationEndpointOwnerDiscovered event on the
        // CollaborationPlatform for the provisioned application.
        void Platform_ApplicationEndpointOwnerDiscovered(object sender,
                                                         ApplicationEndpointSettingsDiscoveredEventArgs e)
        {
            Console.WriteLine("ApplicationEndpointOwnerDiscovered event was raised during startup of the "
                              + "CollaborationPlatform.");
            Console.WriteLine("The ApplicationEndpointOwnerConfiguration that corresponds to the provisioned "
                              + "application with ID \'{0}\' are: ", _appID);
            Console.WriteLine("Owner display name is: "
                              + e.ApplicationEndpointSettings.OwnerDisplayName);
            Console.WriteLine("Owner URI is: " + e.ApplicationEndpointSettings.OwnerUri);
            Console.WriteLine("Now retrieving the ApplicationEndpointSettings from the "
                              + "ApplicationEndpointSettingsDiscoveredEventArgs.");
            ApplicationEndpointSettings settings = e.ApplicationEndpointSettings;

            settings.SupportedMimePartContentTypes = new ContentType[] { new ContentType("text/plain") };

            Console.WriteLine("Initializing the ApplicationEndpoint that corresponds to the provisioned "
                              + "application with ID \'{0}\'.", _appID);

            // Initalize the endpoint using the settings retrieved above.
            _appEndpoint = new ApplicationEndpoint(_collabPlatform, settings);
            // Wire up the StateChanged event.
            _appEndpoint.StateChanged += this.Endpoint_StateChanged;
            // Wire up the ApplicationEndpointOwnerPropertiesChanged event.
            _appEndpoint.OwnerPropertiesChanged += this.Endpoint_ApplicationEndpointOwnerPropertiesChanged;

            try
            {
                // Establish the endpoint.
                _appEndpoint.BeginEstablish(EndEndpointEstablish, _appEndpoint);
            }
            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): Error handling code.
                Console.WriteLine("Invalid Operation Exception: " + iOpEx.ToString());
            }
        }
Exemple #9
0
        public static void Start()
        {
            try
            {
                var host       = Plugin.LyncPlugin.Configuration.GetString("host");
                var thumbprint = Plugin.LyncPlugin.Configuration.GetString("thumbprint");
                var gruu       = Plugin.LyncPlugin.Configuration.GetString("gruu");
                var trustPort  = Plugin.LyncPlugin.Configuration.GetInt("trustedPort");
                var appPort    = Plugin.LyncPlugin.Configuration.GetInt("appPort");
                var sip        = Plugin.LyncPlugin.Configuration.GetString("accountSip");

                var platformSettings = new ServerPlatformSettings(UserAgent, host, trustPort, gruu, CertificateUtil.GetCertificate(StoreName.My, StoreLocation.LocalMachine, thumbprint));

                Platform    = new CollaborationPlatform(platformSettings);
                AppEndpoint = new ApplicationEndpoint(Platform, new ApplicationEndpointSettings(sip, host, appPort)
                {
                    UseRegistration = true
                });

                Log("Starting Lync platform.");
                Platform.EndStartup(Platform.BeginStartup(null, null));
                Log("Lync platform started.");

                AppEndpoint.EndEstablish(AppEndpoint.BeginEstablish(null, null));

                UserEndpoint = new UserEndpoint(Platform, new UserEndpointSettings(sip, host, appPort)
                {
                    AutomaticPresencePublicationEnabled = true
                });
                UserEndpoint.EndEstablish(UserEndpoint.BeginEstablish(null, null));

                RemotePresence = new RemotePresenceView(UserEndpoint, new RemotePresenceViewSettings());
                RemotePresence.PresenceNotificationReceived += PresenceNotificationReceived;
            }
            catch (Exception ex)
            {
                Error(ex.Message);
            }
        }
Exemple #10
0
        // Registered event handler for the ApplicationEndpointOwnerDiscovered event on the
        // CollaborationPlatform for the provisioned application.
        static void Platform_ApplicationEndpointOwnerDiscovered(object sender,
            ApplicationEndpointSettingsDiscoveredEventArgs e)
        {
            Console.WriteLine("ApplicationEndpointOwnerDiscovered event was raised during startup of the CollaborationPlatform.");
            Console.WriteLine("The ApplicationEndpointOwnerConfiguration that corresponds to the provisioned application are: ");
            Console.WriteLine("Owner display name is: " + e.ApplicationEndpointSettings.OwnerDisplayName);
            Console.WriteLine("Owner URI is: " + e.ApplicationEndpointSettings.OwnerUri);
            Console.WriteLine("Now retrieving the ApplicationEndpointSettings from the ApplicationEndpointSettingsDiscoveredEventArgs.");

            ApplicationEndpointSettings settings = e.ApplicationEndpointSettings;
            settings.AutomaticPresencePublicationEnabled = true;
            settings.SupportedMimePartContentTypes = new ContentType[] { new ContentType("text/plain") };
            settings.Presence.Description = "AlwaysOnlineBot";

            PreferredServiceCapabilities capabilities = settings.Presence.PreferredServiceCapabilities;

            capabilities.ApplicationSharingSupport = CapabilitySupport.Supported;
            capabilities.AudioSupport = CapabilitySupport.Supported;
            capabilities.InstantMessagingSupport = CapabilitySupport.Supported;
            capabilities.VideoSupport = CapabilitySupport.Supported;

            Console.WriteLine("Initializing the ApplicationEndpoint that corresponds to the provisioned application.");

            // Initalize the endpoint using the settings retrieved above.
            _appEndpoint = new ApplicationEndpoint(_collabPlatform, settings);
            // Wire up the StateChanged event.
            _appEndpoint.StateChanged += Endpoint_StateChanged;
            // Wire up the ApplicationEndpointOwnerPropertiesChanged event.
            _appEndpoint.OwnerPropertiesChanged += Endpoint_ApplicationEndpointOwnerPropertiesChanged;

            try
            {
                // Establish the endpoint.
                _appEndpoint.BeginEstablish(EndEndpointEstablish, _appEndpoint);
            }
            catch (InvalidOperationException iOpEx)
            {
                Console.WriteLine("Invalid Operation Exception: " + iOpEx.ToString());
            }
        }
Exemple #11
0
        public ApplicationEndpoint CreateApplicationEndpoint(string contactFriendlyName)
        {
            string prompt = string.Empty;

            if (string.IsNullOrEmpty(contactFriendlyName))
            {
                contactFriendlyName = "Default Contact";
            }

            Console.WriteLine();
            Console.WriteLine("Creating Application Endpoint {0}...", contactFriendlyName);
            Console.WriteLine();

            // If application settings are provided via the app.config file, then use them
            // Else prompt user for details
            if (!ReadApplicationContactConfiguration())
            {
                // Prompt user for server FQDN. If server FQDN was entered before, then let the user use the saved value.
                if (string.IsNullOrEmpty(_serverFqdn))
                {
                    prompt      = "Please enter the FQDN of the Microsoft Lync Server for this topology => ";
                    _serverFqdn = PromptUser(prompt, null);
                }

                if (string.IsNullOrEmpty(_applicationHostFQDN))
                {
                    prompt = "Please enter the FQDN of the Machine that the application service is configured to => ";
                    _applicationHostFQDN = PromptUser(prompt, null);
                }
                if (0 >= _applicationPort)
                {
                    // Prompt user for contact port
                    prompt           = "Please enter the port that the application service is configured to => ";
                    _applicationPort = int.Parse(PromptUser(prompt, null), CultureInfo.InvariantCulture);
                }

                if (string.IsNullOrEmpty(_applicationGruu))
                {
                    // Prompt user for Contact GRUU
                    prompt           = "Please enter the GRUU assigned to the application service => ";
                    _applicationGruu = PromptUser(prompt, null);
                }

                if (string.IsNullOrEmpty(_applicationContactURI))
                {
                    // Prompt user for contact URI
                    prompt = "Please enter the Contact URI in the User@Host format => ";
                    _applicationContactURI = PromptUser(prompt, null);
                    if (!_applicationContactURI.Trim().StartsWith(_sipPrefix, StringComparison.OrdinalIgnoreCase))
                    {
                        _applicationContactURI = _sipPrefix + _applicationContactURI.Trim();
                    }
                }

                if (string.IsNullOrEmpty(_certificateFriendlyName))
                {
                    // Prompt user for contact URI
                    prompt = "Please enter the friendly name of the certificate to be used => ";
                    _certificateFriendlyName = PromptUser(prompt, null);
                }
            }

            // Reuse platform instance so that all endpoints share the same platform.
            if (_serverCollabPlatform == null)
            {
                CreateAndStartServerPlatform();
            }

            // Initalize and register the endpoint.
            // NOTE: the _applicationContactURI should always be of the form "sip:user@host"
            ApplicationEndpointSettings appEndpointSettings = new ApplicationEndpointSettings(_applicationContactURI, _serverFqdn, 5061);

            _applicationEndpoint = new ApplicationEndpoint(_serverCollabPlatform, appEndpointSettings);
            _endpointInitCompletedEvent.Reset();

            Console.WriteLine("Establishing the endpoint...");
            _applicationEndpoint.BeginEstablish(EndEndpointEstablish, _applicationEndpoint);

            // Sync; wait for the registration to complete.
            _endpointInitCompletedEvent.WaitOne();
            Console.WriteLine("Application Endpoint established...");
            return(_applicationEndpoint);
        }
        private void EstablishApplicationEndpoint()
        {
            string contactUri = ConfigurationManager.AppSettings["contactUri"];
            string proxyServerFqdn = ConfigurationManager.AppSettings["proxyServerFqdn"];
            int tlsPort = 5061;
            
            // ApplicationEndpointSettings settings = new ApplicationEndpointSettings(contactUri);                        

            ApplicationEndpointSettings settings = new ApplicationEndpointSettings(contactUri, proxyServerFqdn, tlsPort);
            settings.UseRegistration = true;

            settings.AutomaticPresencePublicationEnabled = true;
            settings.Presence.PresentityType = "automaton";
            settings.Presence.Description = "Always available !";

            PreferredServiceCapabilities capabilities = settings.Presence.PreferredServiceCapabilities;
            capabilities.InstantMessagingSupport = CapabilitySupport.Supported;
            capabilities.AudioSupport = CapabilitySupport.Supported;
            capabilities.VideoSupport = CapabilitySupport.Supported;
            capabilities.ApplicationSharingSupport = CapabilitySupport.Supported;

            _appEndpoint = new ApplicationEndpoint(_collaborationPlatform, settings);
            _appEndpoint.StateChanged += new EventHandler<LocalEndpointStateChangedEventArgs>(_appEndpoint_StateChanged);

            // Register to be notified of incoming calls
            _appEndpoint.RegisterForIncomingCall<AudioVideoCall>(OnAudioVideoCallReceived);
            
            // Register to be notified of incoming instant messaging calls
            _appEndpoint.RegisterForIncomingCall<InstantMessagingCall>(OnInstantMessagingCallReceived);

            _logger.Log("Establishing application endpoint...");
            _appEndpoint.BeginEstablish(OnApplicationEndpointEstablishCompleted, null);
        }
        private void OnApplicationEndpointSettingsDiscovered(object sender, ApplicationEndpointSettingsDiscoveredEventArgs args)
        {
            // Keep track of how many endpoints we've found
            // so that we only take one.
            Interlocked.Increment(ref _endpointsDiscovered);

            if (_endpointsDiscovered > 1)
            {
                // We've already found an endpoint
                // and we don't need another one. Sorry!
                return;
            }

            _appEndpoint = new ApplicationEndpoint(_collaborationPlatform, args.ApplicationEndpointSettings);

            _appEndpoint.BeginEstablish(OnApplicationEndpointEstablishCompleted, null);
        }
Exemple #14
0
        /// <summary>
        /// Callback from <code>BeginStartup</code> method on platform.
        /// </summary>
        /// <param name="result">
        /// Status of the platform startup operation.
        /// </param>
        private void PlatformStartupCompleted(IAsyncResult result)
        {
            // Extract the platform that was passed in as the state argument to
            // the BeginStartup() method.
            CollaborationPlatform platform = result.AsyncState as CollaborationPlatform;

            if (platform == null)
            {
                UCMASampleHelper.WriteErrorLine("CollaborationPlatform not passed into BeginStartup() method.");
                UCMASampleHelper.FinishSample();
                return;
            }

            try
            {
                // Determine whether the startup operation completed
                // successfully.
                platform.EndStartup(result);

                UCMASampleHelper.WriteLine("Platform has been started.");
            }
            catch (TlsFailureException tlsFailureException)
            {
                // TlsFailureException will be thrown if the certificate used to
                // startup the platform is invalid or otherwise unusable.
                // TODO (Left to the reader): Error handling code to either
                // retry the platform startup operation with a different
                // certificate, log the error for debugging, or gracefully exit
                // the program.
                UCMASampleHelper.WriteException(tlsFailureException);
                UCMASampleHelper.FinishSample();
            }
            catch (ConnectionFailureException connectionFailureException)
            {
                // ConnectionFailureException will be thrown when the platform
                // could not listen on any of the configured IP/port
                // combinations.
                // TODO (Left to the reader): Error handling code to notify user
                // the configured IP address cannot be used or some other
                // process is already using the port, log the error for
                // debugging, or gracefully exit the program.
                UCMASampleHelper.WriteException(connectionFailureException);
                UCMASampleHelper.FinishSample();
            }
            catch (RealTimeException realTimeException)
            {
                // RealTimeException will be thrown when the platform startup
                // operation failed for some other reason.
                // TODO (Left to the reader): Error handling code to notify user
                // the configured IP address cannot be used or some other
                // process is already using the port, log the error for
                // debugging, or gracefully exit the program.
                UCMASampleHelper.WriteException(realTimeException);
                UCMASampleHelper.FinishSample();
            }
            try
            {
                // Create the ApplicationEndpointSettings.
                _endpointSettings = new ApplicationEndpointSettings(_endpointOwnerURI,
                                                                    _registrarFQDN,
                                                                    _registrarPort);

                // Create the ApplicationEndpoint from the
                // ApplicationEndpointSettings and bind it to the platform.
                _endpoint = new ApplicationEndpoint(platform, _endpointSettings);

                // Bind an event handler to notify when the endpoint changes
                // state.
                _endpoint.StateChanged += new EventHandler <LocalEndpointStateChangedEventArgs>(
                    _endpoint_StateChanged);

                // Establish the endpoint so that it can receive incoming calls
                // and conference invitations. EndEndpointEstablish()  will be
                // called when the endpoint finishes establishment.
                _endpoint.BeginEstablish(EndpointEstablishmentCompleted, _endpoint);

                UCMASampleHelper.WriteLine("Endpoint has been established.");
            }
            catch (ArgumentNullException argumentNullException)
            {
                // ArgumentNullException will be thrown if the parameters used to
                // construct ApplicationEndpointSettings or ApplicationEndpoint
                // are null.
                // TODO (Left to the reader): Error handling code to either
                // retry creating the endpoint with non-null parameters, log the
                // error for debugging or gracefully exit the program.
                UCMASampleHelper.WriteException(argumentNullException);
                UCMASampleHelper.FinishSample();
            }
            catch (ArgumentException argumentException)
            {
                // ArgumentException will be thrown if the parameters used to
                // construct ApplicationEndpointSettings or ApplicationEndpoint
                // are invalid.
                // TODO (Left to the reader): Error handling code to either
                // retry creating the endpoint with corrected parameters, log
                // the error for debugging or gracefully exit the program.
                UCMASampleHelper.WriteException(argumentException);
                UCMASampleHelper.FinishSample();
            }
            catch (InvalidOperationException invalidOperationException)
            {
                // InvalidOperationException will be thrown if the platform is
                // already shutdown, an endpoint with the same SIP URI already
                // exists, or the endpoint has already been established or
                // terminated.
                // TODO (Left to the reader): Error handling code to log the
                // error for debugging.
                UCMASampleHelper.WriteException(invalidOperationException);
                UCMASampleHelper.FinishSample();
            }
        }