public ActionResult DiscoverServices()
 {
     IServiceDiscoverer discoverer = new ServiceDiscoverer();
     var sets = discoverer.DiscoverSets(TimeSpan.FromSeconds(5));
     return Json(sets.DistinctBy(x => x.GetSetIdentifier()).Select(x => new FoundServicesModel(x)), JsonRequestBehavior.AllowGet);
 }
示例#2
0
        private bool PerformCheck()
        {
            IServiceDiscoverer discoverer = new ServiceDiscoverer();
            foreach (IServiceAddressSet set in discoverer.DiscoverSets(TimeSpan.FromSeconds(15)))
            {
                if (set.MASStream == null)
                {
                    Log.Trace("Found service set {0} without MAS stream, ignoring...", set.GetSetIdentifier());
                    continue;
                }

                Log.Trace("Found service set {0} with MAS streams at {1}", set.GetSetIdentifier(), set.MASStream);
                string ipAddress = set.MASStream.Substring(0, set.MASStream.IndexOf(':'));
                if (!alreadyHandledClients.Contains(set.MASStream) && !NetworkInformation.IsLocalAddress(ipAddress))
                {
                    Log.Debug("Going to download channel logos from MAS installation at {0}", set.MASStream);
                    if(!DownloadChannelLogos(logos, set.Connect()))
                    {
                        Log.Debug("Failed to download them without authorization, trying all our local accounts");
                        foreach (var user in Configuration.Authentication.Users)
                        {
                            if (DownloadChannelLogos(logos, set.Connect(user.Username, user.GetPassword())))
                            {
                                Log.Debug("Downloaded channel logos with account {0}", user.Username);
                                break;
                            }
                        }
                    }
                    alreadyHandledClients.Add(set.MASStream);
                }
            }

            // exit if we got all the logos
            ScanForRequiredLogos();
            if (channelLogosRequired.Count == 0)
            {
                Log.Trace("Yes, got all channel logos now!");
                return true;
            }
            else
            {
                return false;
            }
        }