示例#1
0
 /// <summary>
 /// Use this constructor to initialize the stores to the same instance.
 /// </summary>
 public Dht(ID id, IProtocol protocol, Func <IStorage> storageFactory, BaseRouter router)
 {
     originatorStorage = storageFactory();
     republishStorage  = storageFactory();
     cacheStorage      = storageFactory();
     FinishInitialization(id, protocol, router);
     SetupTimers();
 }
示例#2
0
 /// <summary>
 /// Supports different concrete storage types.  For example, you may want the cacheStorage
 /// to be an in memory store, the originatorStorage to be a SQL database, and the republish store
 /// to be a key-value database.
 /// </summary>
 public Dht(ID id, IProtocol protocol, BaseRouter router, IStorage originatorStorage, IStorage republishStorage, IStorage cacheStorage)
 {
     this.originatorStorage = originatorStorage;
     this.republishStorage  = republishStorage;
     this.cacheStorage      = cacheStorage;
     FinishInitialization(id, protocol, router);
     SetupTimers();
 }
示例#3
0
        public static void Initialize(BaseRouter router,
                                      BaseResourcesService resourcesService)
        {
            var       serviceLayer = ServiceLayer.Instance;
            DataStore store        = new DataStore();

            serviceLayer.Register(store);
            serviceLayer.Register(router);
            serviceLayer.Register(resourcesService);
            resourcesService.Initialize();
            store.Initialize();
            router.Initialize();
        }
示例#4
0
 protected void FinishInitialization(ID id, IProtocol protocol, BaseRouter router)
 {
     evictionCount       = new ConcurrentDictionary <BigInteger, int>();
     pendingContacts     = new List <Contact>();
     ourId               = id;
     ourContact          = new Contact(protocol, id);
     node                = new Node(ourContact, republishStorage, cacheStorage);
     node.Dht            = this;
     node.BucketList.Dht = this;
     this.protocol       = protocol;
     this.router         = router;
     this.router.Node    = node;
     this.router.Dht     = this;
 }
示例#5
0
 public override async Task ProcessRequestAsync(HttpContext context)
 {
     await BaseRouter.CallControllerAsync(this, context);
 }