/// <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());
            }
        }
Example #2
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);
     });
 }
            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);
            }
Example #4
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);
            }
        }
Example #5
0
        /// <summary>
        /// Callback method for endpoint establishment completion operation.
        /// </summary>
        /// <param name="result">Async result</param>
        private void EndpointEstablishCompleted(IAsyncResult result)
        {
            ApplicationEndpoint appEndpoint = result.AsyncState as ApplicationEndpoint;
            bool needCleanup = true;

            try
            {
                appEndpoint.EndEstablish(result);

                Helper.Logger.Info("Application Endpoint successfully established");
                needCleanup = false;
            }
            catch (InvalidOperationException ioe)
            {
                Helper.Logger.Error("Endpoint Endpoint operation threw an exception {0}", EventLogger.ToString(ioe));
            }
            catch (RealTimeException rte)
            {
                Helper.Logger.Error("Endpoint Endpoint operation threw an exception {0}", EventLogger.ToString(rte));
            }
            finally
            {
                if (needCleanup)
                {
                    this.Cleanup();
                }
                else
                {
                    var allDone = m_allDone;
                    if (allDone != null)
                    {
                        allDone.Set();
                    }
                }
            }
        }
Example #6
0
        /// <summary>
        /// Callback from <code>BeginEstablish</code> method on endpoint.
        /// </summary>
        /// <param name="result">
        /// Status of the endpoint establishment operation.
        /// </param>
        private void EndpointEstablishmentCompleted(IAsyncResult result)
        {
            // Extract the endpoint that was passed in as the state argument to
            // the BeginEstablish() method.
            ApplicationEndpoint endpoint = result.AsyncState as ApplicationEndpoint;

            if (endpoint == null)
            {
                UCMASampleHelper.WriteErrorLine("ApplicationEndpoint not passed into BeginEstablish() method.");
                UCMASampleHelper.FinishSample();
                return;
            }

            try
            {
                // Determine whether the establish operation completed
                // successfully.
                endpoint.EndEstablish(result);

                // Endpoint state change event handler will log the successful
                // establishment of the endpoint.
                UCMASampleHelper.FinishSample();
            }
            catch (ConnectionFailureException connectionFailureException)
            {
                // ConnectionFailureException will be thrown when no connection
                // can be made to the server.
                // TODO (Left to the reader): Error handling code to either
                // retry establishing the endpoint, log the error for debugging
                // or gracefully exit the program.
                UCMASampleHelper.WriteException(connectionFailureException);
                UCMASampleHelper.FinishSample();
            }
            catch (OperationFailureException operationFailureException)
            {
                // OperationFailureException will be thrown if the retrieval of
                // in-band provisioning data fails.
                // TODO (Left to the reader): Error handling code to either
                // retry establishing the endpoint, log the error for debugging
                // or gracefully exit the program.
                UCMASampleHelper.WriteException(operationFailureException);
                UCMASampleHelper.FinishSample();
            }
            catch (RegisterException registerException)
            {
                // RegisterException will be thrown if the SIP REGISTER
                // operation fails.
                // TODO (Left to the reader): Error handling code to either
                // retry establishing the endpoint, log the error for debugging
                // or gracefully exit the program.
                UCMASampleHelper.WriteException(registerException);
                UCMASampleHelper.FinishSample();
            }
            catch (AuthenticationException authenticationException)
            {
                // AuthenticationException will be thrown if general
                // authentication-related problem occur.
                // TODO (Left to the reader): Error handling code to either
                // retry establishing the endpoint, log the error for debugging
                // or gracefully exit the program.
                UCMASampleHelper.WriteException(authenticationException);
                UCMASampleHelper.FinishSample();
            }
            catch (OperationTimeoutException operationTimeoutException)
            {
                // OperationTimeoutException will be thrown if the registrar
                // server does not respond to REGISTER request.
                // TODO (Left to the reader): Error handling code to either
                // retry establishing the endpoint, log the error for debugging
                // or gracefully exit the program.
                UCMASampleHelper.WriteException(operationTimeoutException);
                UCMASampleHelper.FinishSample();
            }
            catch (RealTimeException realTimeException)
            {
                // RealTimeException will be thrown if the endpoint establish
                // operation fails due to some other issue.
                // TODO (Left to the reader): Error handling code to either
                // retry establishing the endpoint, log the error for debugging
                // or gracefully exit the program.
                UCMASampleHelper.WriteException(realTimeException);
                UCMASampleHelper.FinishSample();
            }
        }