コード例 #1
0
 public RoutingInfo(SimpleIterativeRouter2 router, Key dest, int numOfCandidates, int numOfSimultaneous, bool strict_mode, AsyncCallback callback, object state)
 {
     _router = router;
     _dest = dest;
     _numOfCandidates = numOfCandidates;
     _numOfSimultaneous = numOfSimultaneous;
     _callback = callback;
     _state = state;
     _strictLookup = strict_mode;
     _slots = new HopSlot[router.RoutingAlgorithm.MaxRoutingLevel + 1];
     _startTime = DateTime.Now;
     _timeout = DateTime.Now + TimeSpan.FromSeconds (10);
     _query1 = new NextHopQuery (router.SelftNodeId, router.SelfTcpPort, dest, numOfSimultaneous * 2, numOfCandidates);
     _query2 = new CloseNodeQuery (router.SelftNodeId, router.SelfTcpPort, dest, numOfCandidates);
 }
コード例 #2
0
ファイル: KBREnvironment.cs プロジェクト: kazuki/p2pncs
 public void AddNodes(Key[] keys, ECKeyPair[] keyPairs)
 {
     for (int i = 0; i < keys.Length; i++) {
         IPAddress adrs = _ipGenerator.Next ();
         IPEndPoint ep = new IPEndPoint (adrs, 10000);
         VirtualDatagramEventSocket sock = new VirtualDatagramEventSocket (_network, adrs);
         sock.Bind (new IPEndPoint (IPAddress.Loopback, ep.Port));
         //IMessagingSocket msock = new MessagingSocket (sock, true, SymmetricKey.NoneKey, Serializer.Instance, null, _interrupter, TimeSpan.FromSeconds (1), 2, 1024);
         IMessagingSocket msock = new VirtualMessagingSocket (sock, true, _interrupter, _rtoAlgo, 2, 1024, 1024);
         _sockets.Add (msock);
         IKeyBasedRouter router = new SimpleIterativeRouter2 (keys[i], 0, msock, new SimpleRoutingAlgorithm (), Serializer.Instance, true);
         _routers.Add (router);
         if (_dhts != null) {
             IDistributedHashTable dht = new SimpleDHT (router, msock, new OnMemoryLocalHashTable (router, _dhtInt));
             _dhts.Add (dht);
             if (_anons != null) {
                 IAnonymousRouter anonRouter = new AnonymousRouter (dht, keyPairs[i], _anonInt);
                 _anons.Add (anonRouter);
             }
         }
         if (_endPoints.Count != 0) {
             if (_initEPs == null || _endPoints.Count < 3)
                 _initEPs = _endPoints.ToArray ();
             router.Join (_initEPs);
         }
         _endPoints.Add (ep);
         Thread.Sleep (5);
     }
     Thread.Sleep (500);
 }