コード例 #1
0
ファイル: NetProvider.cs プロジェクト: Trigun27/CheckSum
        // Обновление равноправных участников
        public void RefreshHosts()
        {
            logger.Info("КТО: пользователь {0}. ЧТО: попытка обновления хостов. РЕЗУЛЬТАТ: в процессе",
                LocalPeer.DisplayString);

            // Создание распознавателя и добавление обработчиков событий
            var resolver = new PeerNameResolver();
            resolver.ResolveProgressChanged += resolver_ResolveProgressChanged;
            resolver.ResolveCompleted += resolver_ResolveCompleted;

            // Подготовка к добавлению новых пиров
            PeerList.Clear();

            // Запустить процесс преобразования незащищенных имен пиров асинхронно
            resolver.ResolveAsync(new PeerName("0.P2P_Checksum"), 1);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: spzenk/sfdocsamples
        static void Main(string[] args)
        {
            Console.Write("Peer Classifier to Resolve: ");
            string classifier = Console.ReadLine();
            
            PeerNameResolver resolver = new PeerNameResolver();

            Console.Write("Please wait. Resolving...");

            try
            {
                //records = resolver.Resolve(new PeerName(classifier, PeerNameType.Unsecured));
                //DisplayResults();

                resolver.ResolveCompleted += new EventHandler<ResolveCompletedEventArgs>(resolver_ResolveCompleted);
                resolver.ResolveProgressChanged += new EventHandler<ResolveProgressChangedEventArgs>(resolver_ResolveProgressChanged);
                resolver.ResolveAsync(new PeerName(classifier, PeerNameType.Unsecured), Guid.NewGuid());

                while (isRunning)
                {
                    Thread.Sleep(1000);
                    //Console.Write(".");
                }

            }
            catch (PeerToPeerException ex)
            {
                Console.WriteLine("PeerToPeer Exception: {0}", ex.Message);
               
            }

            Console.WriteLine();
            Console.WriteLine("Press Enter to Exit...");
            Console.ReadLine();

            
        }
コード例 #3
0
ファイル: MainWindow.xaml.cs プロジェクト: kozintsev/ETools
        private void RefreshButton_Click(object sender, RoutedEventArgs e)
        {
            // Создание распознавателя и добавление обработчиков событий
            PeerNameResolver resolver = new PeerNameResolver();
            resolver.ResolveProgressChanged +=
                new EventHandler<ResolveProgressChangedEventArgs>(resolver_ResolveProgressChanged);
            resolver.ResolveCompleted +=
                new EventHandler<ResolveCompletedEventArgs>(resolver_ResolveCompleted);

            // Подготовка к добавлению новых пиров
            PeerList.Items.Clear();
            RefreshButton.IsEnabled = false;

            // Преобразование незащищенных имен пиров асинхронным образом
            resolver.ResolveAsync(new PeerName("0.P2P Sample"), 1);
        }
コード例 #4
0
ファイル: PNRPService.cs プロジェクト: spzenk/sfdocsamples
        public void LookupRegistrationAsync(PeerName peerName, EventHandler<ResolveProgressChangedEventArgs> progressChanged, EventHandler<ResolveCompletedEventArgs> completed)
        {
            if (peerName == null)
                throw new ArgumentException("Cannot have null PeerName");


            _resolver = new PeerNameResolver();

            _resolver.ResolveCompleted += new EventHandler<ResolveCompletedEventArgs>(completed);
            _resolver.ResolveProgressChanged += new EventHandler<ResolveProgressChangedEventArgs>(progressChanged);
            Debug.WriteLine(string.Format("Resolving: {0}", peerName.ToString()));
            _resolver.ResolveAsync(peerName, peerName);

        }