public SendQueryEventArgs(IPEndPoint endpoint, QueryMessage query, ResponseMessage response) : base(null) { this.endpoint = endpoint; this.query = query; this.response = response; }
public void GetPeersEncode() { GetPeers m = new GetPeers(id, infohash); m.TransactionId = transactionId; Compare(m, "d1:ad2:id20:abcdefghij01234567899:info_hash20:mnopqrstuvwxyz123456e1:q9:get_peers1:t2:aa1:y1:qe"); message = m; }
public void FindNodeEncode() { FindNode m = new FindNode(id, infohash); m.TransactionId = transactionId; Compare(m, "d1:ad2:id20:abcdefghij01234567896:target20:mnopqrstuvwxyz123456e1:q9:find_node1:t2:aa1:y1:qe"); message = m; }
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; }
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; }
public void AnnouncePeerDecode() { var text = "d1:ad2:id20:abcdefghij01234567899:info_hash20:mnopqrstuvwxyz1234564:porti6881e5:token8:aoeusnthe1:q13:announce_peer1:t2:aa1:y1:qe"; var m = (AnnouncePeer) Decode( "d1:ad2:id20:abcdefghij01234567899:info_hash20:mnopqrstuvwxyz1234564:porti6881e5:token8:aoeusnthe1:q13:announce_peer1:t2:aa1:y1:qe"); Assert.Equal(m.TransactionId, transactionId); Assert.Equal(m.MessageType, QueryMessage.QueryType); Assert.Equal(id, m.Id); Assert.Equal(infohash, m.InfoHash); Assert.Equal(6881, m.Port); Assert.Equal(token, m.Token); Compare(m, text); message = m; }
public SendQueryTask(DhtEngine engine, QueryMessage query, Node node) : this(engine, query, node, 3) { }
private void RaiseMessageSent(IPEndPoint endpoint, QueryMessage query, ResponseMessage response) { EventHandler<SendQueryEventArgs> h = QuerySent; if (h != null) h(this, new SendQueryEventArgs(endpoint, query, response)); }
public GetPeersResponse(BEncodedDictionary d, QueryMessage m) : base(d, m) { }
public FindNodeResponse(BEncodedDictionary d, QueryMessage m) : base(d, m) { }
public static void RegisterSend(QueryMessage message) { messages.Add(message.TransactionId, message); }
public static bool UnregisterSend(QueryMessage message) { return messages.Remove(message.TransactionId); }
public PingResponse(BEncodedDictionary d, QueryMessage m) :base(d, m) { }
public AnnouncePeerResponse(BEncodedDictionary d, QueryMessage m) : base(d, m) { }
protected ResponseMessage(BEncodedDictionary d, QueryMessage m) : base(d) { queryMessage = m; }
public void PingEncode() { Ping m = new Ping(id); m.TransactionId = transactionId; Compare(m, "d1:ad2:id20:abcdefghij0123456789e1:q4:ping1:t2:aa1:y1:qe"); message = m; }
public PingResponse(BEncodedDictionary d, QueryMessage m) : base(d, m) { }