Exemple #1
0
        public void Test_ctor()
        {
            var peersHolder = new DHTPeersHolder();

            var dhtClient = new DHTClient(new IPEndPoint(DHTClient.IPAnyAddress, DHTClient.PublicDHTPort), peersHolder, "x1");

            Assert.IsNotNull(dhtClient);
            Assert.IsNotNull(dhtClient.LocalID);
            Assert.IsNotNull(dhtClient.Socket);
            Assert.AreEqual(new IPEndPoint(DHTClient.IPAnyAddress, DHTClient.PublicDHTPort), dhtClient.LocalEndPoint);

            dhtClient.PeersFound       += OnPeersFound;
            dhtClient.PeerPinged       += OnPeerPinged;
            dhtClient.QueryReceived    += OnQueryReceive;
            dhtClient.ResponseReceived += OnResponseReceive;
        }
Exemple #2
0
        public void Test_ctor()
        {
            var peersHolder = new DHTPeersHolder();

            var dhtClient = new DHTClient(DHTClient.IPAnyAddress, DHTClient.PublicDHTPort, peersHolder, "x1");

            Assert.IsNotNull(dhtClient);
            Assert.IsNotNull(dhtClient.LocalID);
            Assert.IsNotNull(dhtClient.Socket);
            Assert.AreEqual(new IPEndPoint(DHTClient.IPAnyAddress, DHTClient.PublicDHTPort), dhtClient.LocalEndPoint);

            dhtClient.PeersFound       += OnPeersFound;
            dhtClient.PeerPinged       += OnPeerPinged;
            dhtClient.QueryReceived    += OnQueryReceive;
            dhtClient.ResponseReceived += OnResponseReceive;

            var tid = DHTHelper.GetTransactionId();
            var msg = new DHTMessage(MessageType.Query, QueryType.Ping, null);

            dhtClient.SetTransaction(tid, msg);
            Assert.AreEqual(QueryType.Ping, dhtClient.CheckTransaction(tid));
        }