public DefaultNodeProvider(PomeliumOptions pomeliumOptions, IDistributedCache distributedCache, IServerIdentifier serverIdentifier, ISemaphoreProvider semaphoreProvider)
 {
     _pomeliumOptions   = pomeliumOptions;
     _distributedCache  = distributedCache;
     _serverIdentifier  = serverIdentifier;
     _semaphoreProvider = semaphoreProvider;
     _timer             = new Timer(TimeIntervalCallBack, null, 0, 30 * 1000);
 }
Exemple #2
0
 public DistributedSession(
     IDistributedCache distributedCache,
     PomeliumOptions pomeliumOptions,
     AsyncLockers asyncLockers)
 {
     _distributedCache = distributedCache;
     _pomeliumOptions  = pomeliumOptions;
     _prefix           = _pomeliumOptions.SessionCachingPrefix;
     _asyncLockers     = asyncLockers;
 }
Exemple #3
0
 public DefaultClientCollection(
     PomeliumOptions pomeliumOptions,
     IDistributedCache distributedCache,
     INodeProvider nodeProvider,
     IServerIdentifier serverIdentifier,
     AsyncLockers asyncLockers)
 {
     _pomeliumOptions  = pomeliumOptions;
     _distributedCache = distributedCache;
     _nodeProvider     = nodeProvider;
     _serverIdentifier = serverIdentifier;
     _dic          = new Dictionary <Guid, IClient>();
     _asyncLockers = asyncLockers;
 }
Exemple #4
0
 public DefaultGarbageCollector(
     PomeliumOptions pomeliumOptions,
     IClientCollection clientCollection,
     IDistributedCache distributedCache,
     ISession session,
     IServerIdentifier serverIdentifier,
     AsyncLockers asyncLockers)
 {
     _pomeliumOptions  = pomeliumOptions;
     _clientCollection = clientCollection;
     _distributedCache = distributedCache;
     _session          = session;
     _serverIdentifier = serverIdentifier;
     _collectTimer     = new Timer(CollectCallback, null, 0, 1000 * 60);
     _asyncLockers     = asyncLockers;
 }
        public static IServiceCollection AddPomeliumServer <T>(this IServiceCollection self, Action <PomeliumOptions> setup = null)
            where T : PomeliumServer
        {
            var option = new PomeliumOptions();

            setup?.Invoke(option);
            return(self.AddSingleton <T>()
                   .AddSingleton <ISession, DistributedSession>()
                   .AddSingleton <IPomeliumHubLocator, DefaultPomeliumHubLocator>()
                   .AddSingleton <ISemaphoreProvider, DefaultSemaphoreProvider>()
                   .AddSingleton <IHubActivitor, DefaultHubActivitor>()
                   .AddSingleton <IServerIdentifier, DefaultServerIdentifier>()
                   .AddSingleton <INodeProvider, DefaultNodeProvider>()
                   .AddSingleton <IClientCollection, DefaultClientCollection>()
                   .AddSingleton <IGarbageCollector, DefaultGarbageCollector>()
                   .AddSingleton <AsyncLockers>()
                   .AddSingleton(option));
        }