Inheritance: FileFind.Meshwork.FileTransfer.FileTransferPeerBase
        public override void AddPeer(Network network, Node node)
        {
            // Don't allow adding the same node (regardless of network)
            // more than once.
            if (this.peers.Exists(p => p.Node.NodeID == node.NodeID))
            {
                throw new Exception("This node is already a peer.");
            }

            var peer = new BitTorrentFileTransferPeer(network, node);

            peers.Add(peer);

            if (this.manager != null)
            {
                if (Direction == FileTransferDirection.Upload && File.Pieces.Any())
                {
                    peer.Network.SendFileDetails(node, (LocalFile)File);
                }

                if (this.manager.State != TorrentState.Stopped)
                {
                    ConnectToPeer(peer);
                }
            }
        }
        private bool ConnectToPeer(BitTorrentFileTransferPeer peer)
        {
            IDestination destination = peer.Node.FirstConnectableDestination;

            if (destination != null)
            {
                var transport = destination.CreateTransport(ConnectionType.TransferConnection);
                Core.LoggingService.LogDebug("New outgoing connection");
                peer.Network.ConnectTo(transport, OutgoingPeerTransportConnected);
                return(true);
            }

            // FIXME: Mark peer as bad!
            Core.LoggingService.LogError("Transfer can't connect to peer {0} - no destinations available!", peer.Node);
            return(false);
        }
 private bool ConnectToPeer(BitTorrentFileTransferPeer peer)
 {
     IDestination destination = peer.Node.FirstConnectableDestination;
     if (destination != null) {
         ITransport transport = destination.CreateTransport(ConnectionType.TransferConnection);
         LoggingService.LogDebug("New outgoing connection");
         peer.Network.ConnectTo(transport, OutgoingPeerTransportConnected);
         return true;
     } else {
         // FIXME: Mark peer as bad!
         LoggingService.LogError("Transfer can't connect to peer {0} - no destinations available!", peer.Node);
         return false;
     }
 }
        public override void AddPeer(Network network, Node node)
        {
            // Don't allow adding the same node (regardless of network)
            // more than once.
            foreach (BitTorrentFileTransferPeer p in peers) {
                if (p.Node.NodeID == node.NodeID) {
                    throw new Exception("This node is already a peer.");
                }
            }

            BitTorrentFileTransferPeer peer = new BitTorrentFileTransferPeer(network, node);
            peers.Add(peer);

            if ((manager != null) && Direction == FileTransferDirection.Upload && file.Pieces.Length > 0) {
                peer.Network.SendFileDetails(node, (LocalFile)file);
            }

            if (manager == null || manager.State == TorrentState.Stopped) {
                return;
            }

            ConnectToPeer(peer);
        }