internal PeerId(Peer peer, IPeerConnection connection, BitField bitfield)
        {
            Peer = peer;

            AmChoking = true;
            IsChoking = true;

            LastMessageReceived = new ValueStopwatch();
            LastMessageSent     = new ValueStopwatch();
            WhenConnected       = new ValueStopwatch();

            AmAllowedFastPieces = new List <int> ();
            IsAllowedFastPieces = new List <int> ();
            SuggestedPieces     = new List <int> ();

            MaxPendingRequests          = PieceManager.NormalRequestAmount;
            MaxSupportedPendingRequests = Constants.DefaultMaxPendingRequests;
            MessageQueue      = new MessageQueue();
            ExtensionSupports = new ExtensionSupports();
            Monitor           = new ConnectionMonitor();

            InitializeTyrant();

            Connection      = connection ?? throw new ArgumentNullException(nameof(connection));
            Peer            = peer ?? throw new ArgumentNullException(nameof(peer));
            MutableBitField = bitfield;
            Decryptor       = PlainTextEncryption.Instance;
            Encryptor       = PlainTextEncryption.Instance;
        }
Example #2
0
        internal PeerId(Peer peer, TorrentManager manager, IConnection connection)
        {
            Connection     = connection ?? throw new ArgumentNullException(nameof(connection));
            Peer           = peer ?? throw new ArgumentNullException(nameof(peer));
            TorrentManager = manager ?? throw new ArgumentNullException(nameof(manager));

            Engine = manager.Engine;
            if (TorrentManager.HasMetadata)
            {
                BitField = new BitField(TorrentManager.Torrent.Pieces.Count);
            }

            SuggestedPieces = new List <int>();
            AmChoking       = true;
            IsChoking       = true;

            IsAllowedFastPieces         = new List <int>();
            AmAllowedFastPieces         = new List <int>();
            MaxPendingRequests          = 2;
            MaxSupportedPendingRequests = 50;
            Monitor           = new ConnectionMonitor();
            sendQueue         = new List <PeerMessage>(12);
            ExtensionSupports = new ExtensionSupports();

            InitializeTyrant();
        }
Example #3
0
        internal PeerId(Peer peer, TorrentManager manager)
        {
            Peer           = peer ?? throw new ArgumentNullException(nameof(peer));
            TorrentManager = manager;


            SuggestedPieces = new MonoTorrentCollection <int>();
            AmChoking       = true;
            IsChoking       = true;

            IsAllowedFastPieces         = new MonoTorrentCollection <int>();
            AmAllowedFastPieces         = new MonoTorrentCollection <int>();
            MaxPendingRequests          = 2;
            MaxSupportedPendingRequests = 50;
            Monitor           = new ConnectionMonitor();
            sendQueue         = new MonoTorrentCollection <PeerMessage>(12);
            ExtensionSupports = new ExtensionSupports();

            InitializeTyrant();
        }
Example #4
0
        PeerId(Peer peer)
        {
            Peer = peer;

            AmChoking = true;
            IsChoking = true;

            LastMessageReceived = new ValueStopwatch();
            LastMessageSent     = new ValueStopwatch();
            WhenConnected       = new ValueStopwatch();

            AmAllowedFastPieces = new List <int> ();
            IsAllowedFastPieces = new List <int> ();
            SuggestedPieces     = new List <int> ();

            MaxPendingRequests          = PieceManager.NormalRequestAmount;
            MaxSupportedPendingRequests = Constants.DefaultMaxPendingRequests;
            MessageQueue      = new MessageQueue();
            ExtensionSupports = new ExtensionSupports();
            Monitor           = new ConnectionMonitor();

            InitializeTyrant();
        }
Example #5
0
        internal PeerId(Peer peer, TorrentManager manager)
        {
            if (peer == null)
            {
                throw new ArgumentNullException("peer");
            }

            this.suggestedPieces = new MonoTorrentCollection <int>();
            this.amChoking       = true;
            this.isChoking       = true;

            this.isAllowedFastPieces = new MonoTorrentCollection <int>();
            this.amAllowedFastPieces = new MonoTorrentCollection <int>();
            this.lastMessageReceived = DateTime.Now;
            this.lastMessageSent     = DateTime.Now;
            this.peer = peer;
            this.maxPendingRequests          = 2;
            this.maxSupportedPendingRequests = 50;
            this.monitor      = new ConnectionMonitor();
            this.sendQueue    = new MonoTorrentCollection <PeerMessage>(12);
            ExtensionSupports = new ExtensionSupports();
            TorrentManager    = manager;
            InitializeTyrant();
        }
Example #6
0
        PeerId(Peer peer)
        {
            Peer = peer;

            AmChoking = true;
            IsChoking = true;

            LastMessageReceived = new ValueStopwatch();
            LastMessageSent     = new ValueStopwatch();
            WhenConnected       = new ValueStopwatch();

            AmAllowedFastPieces = new List <int>();
            IsAllowedFastPieces = new List <int>();
            SuggestedPieces     = new List <int>();

            MaxPendingRequests          = 2;
            MaxSupportedPendingRequests = 50;

            ExtensionSupports = new ExtensionSupports();
            Monitor           = new ConnectionMonitor();
            SendQueue         = new List <PeerMessage>(12);

            InitializeTyrant();
        }