Esempio n. 1
0
        /// <summary>
        /// Removes a peer from the peer list
        /// </summary>
        /// <param name="Peer">The peer to remove</param>
        public void RemovePeer(P2pPeer Peer)
        {
            // Lock peer list to prevent race conditions
            lock (Peers)
            {
                // Stop this peer
                Peer.Stop();

                // Remove this peer from our peer list
                Peers.RemoveAll(x => x == Peer);
            }
        }
Esempio n. 2
0
        // Handles a new peer client
        private void AddPeer(P2pPeer Peer)
        {
            // Lock peer list to prevent race conditions
            lock (Peers)
            {
                // Check that we have space for this peer
                if (Peers.Count < MaxConnections)
                {
                    Peer.Start();
                    Peers.Add(Peer);
                }

                // No space available, close connection
                else
                {
                    Peer.Stop();
                }
            }
        }