Exemple #1
0
        public override void Execute()
        {
            if (Active)
            {
                return;
            }

            Active = true;

            // If we were given a list of nodes to load at the start, use them
            if (_initialNodes.Count > 0)
            {
                foreach (var node in _initialNodes)
                {
                    _engine.Add(node);
                }
                SendFindNode(_initialNodes);
            }
            else
            {
                try
                {
                    var utorrent = new Node(NodeId.Create(),
                                            new IPEndPoint(Dns.ResolveAddress("router.bittorrent.com"), 6881));
                    SendFindNode(new[] { utorrent });
                }
                catch
                {
                    RaiseComplete(new TaskCompleteEventArgs(this));
                }
            }
        }