/// <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(); }
/// <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(); }
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(); }
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; }
public override async Task ProcessRequestAsync(HttpContext context) { await BaseRouter.CallControllerAsync(this, context); }