示例#1
0
 private void FindCompleted(object sender, FindCompletedEventArgs e)
 {
     if (!e.Cancelled)
     {
         Start();
     }
 }
示例#2
0
        void DiscoveryClient_FindCompleted(object sender, FindCompletedEventArgs e)
        {
            Console.WriteLine("Search completed ({0} results)", e.Result.Endpoints.Count);

            _discoveryClient.FindProgressChanged -= DiscoveryClient_FindProgressChanged;
            _discoveryClient.FindCompleted       -= DiscoveryClient_FindCompleted;

            btnProbe.Enabled = true;
        }
示例#3
0
        private static void DiscoveryClientOnFindCompleted(object sender, FindCompletedEventArgs findCompletedEventArgs)
        {
            var disposable = sender as IDisposable;

            if (disposable != null)
            {
                disposable.Dispose();
            }
        }
示例#4
0
 void ApprovalFindCompleted(object sender, FindCompletedEventArgs e)
 {
     // If we didn't find any endpoints -- the discovery failed
     if (e.Result.Endpoints.Count > 0)
     {
         approvalAddr = e.Result.Endpoints[0].Address;
         DiscoveredCommonOps();
     }
     else
     {
         statusWriter.WriteLine("Discovery Failed");
     }
 }
示例#5
0
        private static void DiscoveryClient_FindCompleted(object sender, FindCompletedEventArgs e)
        {
            Console.WriteLine("Find finished");
            if (e.Result.Endpoints.Count > 0)
            {
                discoveredService = e.Result.Endpoints[0];
                CallService();
            }
            else
            {
                Console.WriteLine("Service not found");
            }

            Console.WriteLine("Now the client really finished");
            Console.ReadLine();
        }
示例#6
0
        private void OnServiceFound(object sender, FindCompletedEventArgs e)
        {
            var endpoints = new List <EndpointDiscoveryMetadata>(e.Result.Endpoints);
            var hostName  = Environment.MachineName.ToLower();
            var hostIndex = endpoints.FindIndex(p => p.Address.Uri.ToString().Contains(hostName));

            if (hostIndex != -1)
            {
                var wHostEndpoint = endpoints[hostIndex];
                endpoints.RemoveAt(hostIndex);
                endpoints.Insert(0, wHostEndpoint);
            }
            foreach (var endpointDiscoveryMetadata in endpoints)
            {
                OnServiceOnlineAnnouncementReceived(endpointDiscoveryMetadata);
            }
        }
示例#7
0
        //private void DoWork()
        //{
        //    var randomizer = new Random(DateTime.Now.Millisecond);



        //    //while (_keepRunningWorkerThread)
        //    //{
        //    //    Thread.Sleep(2000);
        //    //}
        //}

        internal void DiscoveryCompleted(object sender, FindCompletedEventArgs e)
        {
            var newKnownDevices = _discoveryService.GetDevices();

            Console.WriteLine($"{_moduleName}: Discovered completed, {newKnownDevices.Count} found.");

            if (_currentKnownDevices == null)
            {
                AnnounceNewDevices(newKnownDevices);
            }
            else
            {
                CompareDevices(newKnownDevices);
            }

            _currentKnownDevices = newKnownDevices;

            _discoveryService = new DiscoveryService();
            _discoveryService.Discover(_discoveryTimeOutMiliseconds, DiscoveryCompleted);
        }
示例#8
0
        static private void DiscoveryClient_FindCompleted(object sender, FindCompletedEventArgs e)
        {
            Console.WriteLine("DiscoveryClient_FindCompleted(...)");
            if (e.Error != null)
            {
                Console.WriteLine(e.Error);

                return;
            }



            if (!e.Cancelled)
            {
                var result = e.Result;
                if (result != null)
                {
                    foreach (var ep in result.Endpoints)
                    {
                        string address  = ep.Address.ToString();
                        string hostName = address;

                        var extensions = ep.Extensions;
                        if (extensions != null && extensions.Count > 0)
                        {
                            var hostElement = extensions.FirstOrDefault(el => el.Name == "HostName");
                            if (hostElement != null)
                            {
                                hostName = hostElement.Value;                                // + " {" + address + "}";
                            }
                        }

                        Console.WriteLine(hostName + " " + address);
                    }
                }
            }
            else
            {
                Console.WriteLine("ScreenCastControl::FindCompleted(...) Cancelled");
            }
        }
示例#9
0
        private void OnFindCompleted(object sender, FindCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                // 搜索被取消了
            }
            else if (e.Error != null)
            {
                // 搜索过程出现错误
                this.discoveryClient.Close();
                ExceptionHandler.Handle(e.Error);
            }
            else
            {
                if (this.discoveryClient.InnerChannel.State == CommunicationState.Opened)
                {
                    this.discoveryClient.Close();
                }
            }

            this.discoveryClient = null;
        }
示例#10
0
        void FindCompleted(object sender, FindCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                throw e.Error;
            }

            try
            {
                // Ensures that all FindProgressedChanged events are raised before completing the
                // AsyncResult. If there are pending FindProgressedChanged events to be raised, then
                // the AsyncResult will be completed in the FindProgressedChanged method after all
                // events are raised.
                if (Interlocked.Add(ref pendingEndpointCount, -e.Result.Endpoints.Count) == 0)
                {
                    this.Complete(false);
                }
            }
            catch (Exception exception)
            {
                this.Complete(false, exception);
            }
        }
示例#11
0
        //searching for addresses finished
        private static void DiscoveryClient_FindCompleted(object sender, FindCompletedEventArgs e)
        {
            var logger = NLog.LogManager.GetCurrentClassLogger();
            //create list of founded endpoints
            List <Uri> endpointsList = new List <Uri>();

            try
            {
                foreach (var item in e.Result.Endpoints)
                {
                    Uri endpoint = new Uri(item.Address.ToString());
                    endpointsList.Add(endpoint);
                }
            }
            catch (Exception ex)
            {
                logger.Error($"Error while completing search for host endpoints: {ex.Message}. Inner exception: {ex.InnerException}. Stack trace: {ex.StackTrace}.");
            }

            logger.Info("Searching Host endpoints finished. Endpoints founded: " + endpointsList.Count.ToString());

            OnSearchingForEndpointsFinished(endpointsList);
        }
示例#12
0
 static void discoveryClient_FindCompleted(object sender, FindCompletedEventArgs e)
 {
     Console.WriteLine("--------------- Search finished ---------------");
 }
示例#13
0
 private void DiscoveryClientOnFindCompleted(object sender, FindCompletedEventArgs findCompletedEventArgs)
 {
     Logger.Debug("Service discovery completed. Found {0} endpoints", findCompletedEventArgs.Result.Endpoints.Count);
     _isRunning = false;
 }
示例#14
0
 private void DiscoveryClient_FindCompleted(object sender, FindCompletedEventArgs e)
 {
     this.OnRecoveryChange("", DiscoveryEvent.EventTypes.endEvent);
 }
示例#15
0
 static void ClientFindCompleted(object sender, FindCompletedEventArgs e)
 {
     // Implement this method to access the FindResponse object through e.Result, which includes all the endpoints found
 }
示例#16
0
        private void DiscoveryClient_FindCompleted(object sender, FindCompletedEventArgs e)
        {
            tracer.TraceEvent(TraceEventType.Verbose, 0, "ScreenCastControl::FindCompleted(...)");

            // logger.Debug("FindCompleted(...)");

            finding = false;

            List <ComboBoxItem> hostItems = new List <ComboBoxItem>();

            if (e.Cancelled)
            {
                //logger.Debug("Cancelled");
                tracer.Verb("ScreenCastControl::FindCompleted(...) Cancelled");
            }
            if (e.Error != null)
            {
                // logger.Debug(e.Error.ToString());
                tracer.Error(e.Error);
            }


            if (!e.Cancelled)
            {
                var result = e.Result;
                if (result != null)
                {
                    foreach (var ep in result.Endpoints)
                    {
                        string address  = ep.Address.ToString();
                        string hostName = address;

                        var extensions = ep.Extensions;
                        if (extensions != null && extensions.Count > 0)
                        {
                            var hostElement = extensions.FirstOrDefault(el => el.Name == "HostName");
                            if (hostElement != null)
                            {
                                hostName = hostElement.Value;// + " {" + address + "}";
                            }
                        }

                        //logger.Debug(hostName);

                        hostItems.Add(new ComboBoxItem
                        {
                            Name = hostName,
                            Tag  = address,
                        });
                    }
                }
            }

            hostsComboBox.DataSource    = hostItems;
            hostsComboBox.DisplayMember = "Name";

            discoveryClient.Close();
            discoveryClient = null;

            connectButton.Enabled = true;
            hostsComboBox.Enabled = true;

            findServiceButton.Text = "_Find";
            labelStatus.Text       = "_Not Connected";
        }
示例#17
0
 protected void WsBrowserFindCompleted(object sender, FindCompletedEventArgs e)
 {
     OnDiscoveryFinished(new DiscoveryEventArgs());
 }