public SendQueryEventArgs(IPEndPoint endpoint, QueryMessage query, ResponseMessage response)
     : base(null)
 {
     this.endpoint = endpoint;
     this.query = query;
     this.response = response;
 }
Beispiel #2
0
        public void AnnouncePeerDecode()
        {
            string text = "d1:ad2:id20:abcdefghij01234567899:info_hash20:mnopqrstuvwxyz1234564:porti6881e5:token8:aoeusnthe1:q13:announce_peer1:t2:aa1:y1:qe";
            AnnouncePeer m = (AnnouncePeer)Decode("d1:ad2:id20:abcdefghij01234567899:info_hash20:mnopqrstuvwxyz1234564:porti6881e5:token8:aoeusnthe1:q13:announce_peer1:t2:aa1:y1:qe");
            Assert.AreEqual(m.TransactionId, _transactionId, "#1");
            Assert.AreEqual(m.MessageType, QueryMessage.QueryType, "#2");
            Assert.AreEqual(_id, m.Id, "#3");
            Assert.AreEqual(_infohash, m.InfoHash, "#3");
            Assert.AreEqual((BEncodedNumber)6881, m.Port, "#4");
            Assert.AreEqual(_token, m.Token, "#5");

            Compare(m, text);
            _message = m;
        }
Beispiel #3
0
        public SendQueryTask(DhtEngine engine, QueryMessage query, Node node, int retries)
        {
            if (engine == null)
                throw new ArgumentNullException("engine");
            if (query == null)
                throw new ArgumentNullException("message");
            if (node == null)
                throw new ArgumentNullException("message");

            this.engine = engine;
            this.query = query;
            this.node = node;
            this.retries = retries;
            this.origRetries = retries;
        }
Beispiel #4
0
 public PingResponse(BEncodedDictionary d, QueryMessage m)
     : base(d, m)
 {
 }
 protected ResponseMessage(BEncodedDictionary d, QueryMessage m)
     : base(d)
 {
     queryMessage = m;
 }
 public FindNodeResponse(BEncodedDictionary d, QueryMessage m)
     : base(d, m)
 {
 }
Beispiel #7
0
        public void FindNodeEncode()
        {
            var message = new FindNode(_id, _infohash) {TransactionId = _transactionId};

            Compare(message, "d1:ad2:id20:abcdefghij01234567896:target20:mnopqrstuvwxyz123456e1:q9:find_node1:t2:aa1:y1:qe");
            _message = message;
        }
Beispiel #8
0
        public void PingEncode()
        {
            var m = new Ping(_id) {TransactionId = _transactionId};

            Compare(m, "d1:ad2:id20:abcdefghij0123456789e1:q4:ping1:t2:aa1:y1:qe");
            _message = m;
        }
Beispiel #9
0
        public void GetPeersEncode()
        {
            var m = new GetPeers(_id, _infohash) {TransactionId = _transactionId};

            Compare(m, "d1:ad2:id20:abcdefghij01234567899:info_hash20:mnopqrstuvwxyz123456e1:q9:get_peers1:t2:aa1:y1:qe");
            _message = m;
        }
 public AnnouncePeerResponse(BEncodedDictionary d, QueryMessage m)
     : base(d, m)
 {
 }
Beispiel #11
0
 private void RaiseMessageSent(IPEndPoint endpoint, QueryMessage query, ResponseMessage response)
 {
     EventHandler<SendQueryEventArgs> h = QuerySent;
     if (h != null)
         h(this, new SendQueryEventArgs(endpoint, query, response));
 }
Beispiel #12
0
 public SendQueryTask(DhtEngine engine, QueryMessage query, Node node)
     : this(engine, query, node, 3)
 {
 }
Beispiel #13
0
 public static void RegisterSend(QueryMessage message)
 {
     messages.Add(message.TransactionId, message);
 }
Beispiel #14
0
 public static bool UnregisterSend(QueryMessage message)
 {
     return messages.Remove(message.TransactionId);
 }
Beispiel #15
0
 protected ResponseMessage(BEncodedDictionary d, QueryMessage m)
     : base(d)
 {
     _queryMessage = m;
 }