Inheritance: OctoTorrent.Dht.Messages.ResponseMessage
Ejemplo n.º 1
0
        public override void Handle(DhtEngine engine, Node node)
        {
            base.Handle(engine, node);

            if (!engine.Torrents.ContainsKey(InfoHash))
            {
                engine.Torrents.Add(InfoHash, new List <Node>());
            }

            Message response;

            if (engine.TokenManager.VerifyToken(node, Token))
            {
                engine.Torrents[InfoHash].Add(node);
                response = new AnnouncePeerResponse(engine.RoutingTable.LocalNode.Id, TransactionId);
            }
            else
            {
                response = new ErrorMessage(ErrorCode.ProtocolError, "Invalid or expired token received");
            }

            engine.MessageLoop.EnqueueSend(response, node.EndPoint);
        }
Ejemplo n.º 2
0
        public void AnnouncePeerResponseEncode()
        {
            var message = new AnnouncePeerResponse(_infohash, _transactionId);

            Compare(message, "d1:rd2:id20:mnopqrstuvwxyz123456e1:t2:aa1:y1:re");
        }
Ejemplo n.º 3
0
        public override void Handle(DhtEngine engine, Node node)
        {
            base.Handle(engine, node);

            if (!engine.Torrents.ContainsKey(InfoHash))
                engine.Torrents.Add(InfoHash, new List<Node>());

            Message response;
            if (engine.TokenManager.VerifyToken(node, Token))
			{
                engine.Torrents[InfoHash].Add(node);
				response = new AnnouncePeerResponse(engine.RoutingTable.LocalNode.Id, TransactionId);
		    }
			else
			    response = new ErrorMessage(ErrorCode.ProtocolError, "Invalid or expired token received");
				
			engine.MessageLoop.EnqueueSend(response, node.EndPoint);
        }