Beispiel #1
0
        public void DisconnectPeer(Peer peer, Exception ex)
        {
            if (ex != null)
                logger.Debug(ex, $"Remote peer failed: {peer.RemoteEndPoint}");

            PeerDisconnected?.Invoke(peer);

            if (peer.IsIncoming)
                Interlocked.Decrement(ref this.incomingCount);

            this.badPeers.Add(peer.RemoteEndPoint); //TODO

            this.unconnectedPeersLock.Do(() =>
                this.unconnectedPeers.Remove(peer.RemoteEndPoint));
            this.pendingPeers.TryRemove(peer);
            this.connectedPeers.TryRemove(peer);

            peer.OnDisconnect -= DisconnectPeer;
            peer.Dispose();
        }
Beispiel #2
0
        public void DisconnectPeer(Peer peer, Exception ex)
        {
            if (ex != null)
                logger.Debug(ex, $"Remote peer failed: {peer.RemoteEndPoint}");

            RaisePeerDisconnected(peer);

            this.badPeers.Add(peer.RemoteEndPoint); //TODO

            this.unconnectedPeersLock.Do(() =>
                this.unconnectedPeers.Remove(peer.RemoteEndPoint));
            this.pendingPeers.TryRemove(peer);
            this.connectedPeers.TryRemove(peer);

            peer.OnDisconnect -= DisconnectPeer;
            peer.Dispose();
        }