예제 #1
0
        public ServerManager(BufferManager bufferManager)
        {
            _bufferManager = bufferManager;

            _settings = new Settings(this.ThisLock);

            _watchTimer = new WatchTimer(this.WatchTimer, Timeout.Infinite);
        }
예제 #2
0
        public ServerManager(BufferManager bufferManager)
        {
            _bufferManager = bufferManager;

            _settings = new Settings(this.ThisLock);

            _watchTimer = new WatchTimer(this.WatchTimer, Timeout.Infinite);
        }
예제 #3
0
        public DownloadManager(ConnectionsManager connectionsManager, CacheManager cacheManager, BufferManager bufferManager)
        {
            _connectionsManager = connectionsManager;
            _cacheManager       = cacheManager;
            _bufferManager      = bufferManager;

            _settings = new Settings(this.ThisLock);

            _watchTimer = new WatchTimer(this.WatchTimer, Timeout.Infinite);
        }
예제 #4
0
        public UploadManager(ConnectionsManager connectionsManager, CacheManager cacheManager, BufferManager bufferManager)
        {
            _connectionsManager = connectionsManager;
            _cacheManager = cacheManager;
            _bufferManager = bufferManager;

            _settings = new Settings(this.ThisLock);

            _watchTimer = new WatchTimer(this.WatchTimer, Timeout.Infinite);
        }
예제 #5
0
        public CacheManager(string cachePath, BitmapManager bitmapManager, BufferManager bufferManager)
        {
            _fileStream    = new FileStream(cachePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None, 8192, FileOptions.None);
            _bitmapManager = bitmapManager;
            _bufferManager = bufferManager;

            _settings = new Settings(this.ThisLock);

            _threadCount = Math.Max(1, Math.Min(System.Environment.ProcessorCount, 32) / 4);

            _watchTimer = new WatchTimer(this.WatchTimer, Timeout.Infinite);
        }
예제 #6
0
        public DownloadManager(ConnectionsManager connectionsManager, CacheManager cacheManager, BufferManager bufferManager)
        {
            _connectionsManager = connectionsManager;
            _cacheManager = cacheManager;
            _bufferManager = bufferManager;

            _cache_Metadata_Profile_Pairs = new VolatileHashDictionary<ProfileMetadata, Profile>(new TimeSpan(0, 30, 0));
            _cache_Metadata_SignatureMessage_Pairs_Dictionary = new VolatileHashDictionary<string, Dictionary<SignatureMessageMetadata, SignatureMessage>>(new TimeSpan(0, 30, 0));
            _cache_Metadata_WikiDocument_Pairs_Dictionary = new VolatileHashDictionary<Wiki, Dictionary<WikiDocumentMetadata, WikiDocument>>(new TimeSpan(0, 30, 0));
            _cache_Metadata_ChatMessage_Pairs_Dictionary = new VolatileHashDictionary<Chat, Dictionary<ChatMessageMetadata, ChatMessage>>(new TimeSpan(0, 30, 0));

            _watchTimer = new WatchTimer(this.WatchTimer, new TimeSpan(0, 0, 30));

            _settings = new Settings(this.ThisLock);

            _connectionsManager.GetLockSignaturesEvent = (object sender) =>
            {
                var signatures = new HashSet<string>();
                signatures.UnionWith(_settings.TrustSignatures);
                signatures.UnionWith(_cache_Metadata_Profile_Pairs.Keys.Select(n => n.Certificate.ToString()));
                signatures.UnionWith(_cache_Metadata_SignatureMessage_Pairs_Dictionary.Keys);

                return signatures;
            };

            _connectionsManager.GetLockWikisEvent = (object sender) =>
            {
                var wikis = new HashSet<Wiki>();
                wikis.UnionWith(_cache_Metadata_WikiDocument_Pairs_Dictionary.Keys);

                return wikis;
            };

            _connectionsManager.GetLockChatsEvent = (object sender) =>
            {
                var chats = new HashSet<Chat>();
                chats.UnionWith(_cache_Metadata_ChatMessage_Pairs_Dictionary.Keys);

                return chats;
            };
        }
예제 #7
0
        protected override void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }
            _disposed = true;

            if (disposing)
            {
                if (_fileStream != null)
                {
                    try
                    {
                        _fileStream.Dispose();
                    }
                    catch (Exception)
                    {
                    }

                    _fileStream = null;
                }

                if (_watchTimer != null)
                {
                    try
                    {
                        _watchTimer.Dispose();
                    }
                    catch (Exception)
                    {
                    }

                    _watchTimer = null;
                }
            }
        }
예제 #8
0
        protected override void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }
            _disposed = true;

            if (disposing)
            {
                if (_refreshTimer != null)
                {
                    try
                    {
                        _refreshTimer.Dispose();
                    }
                    catch (Exception)
                    {
                    }

                    _refreshTimer = null;
                }
            }
        }
예제 #9
0
        protected override void Dispose(bool disposing)
        {
            if (_disposed) return;
            _disposed = true;

            if (disposing)
            {
                if (_watchTimer != null)
                {
                    try
                    {
                        _watchTimer.Dispose();
                    }
                    catch (Exception)
                    {

                    }

                    _watchTimer = null;
                }
            }
        }
예제 #10
0
 public MessagesManager()
 {
     _refreshTimer = new WatchTimer(this.RefreshTimer, new TimeSpan(0, 0, 30));
 }
예제 #11
0
 public MessagesManager()
 {
     _refreshTimer = new WatchTimer(this.RefreshTimer, new TimeSpan(0, 0, 30));
 }
예제 #12
0
        protected override void Dispose(bool disposing)
        {
            if (_disposed) return;
            _disposed = true;

            if (disposing)
            {
                if (_refreshTimer != null)
                {
                    try
                    {
                        _refreshTimer.Dispose();
                    }
                    catch (Exception)
                    {

                    }

                    _refreshTimer = null;
                }

                if (_messagesManager != null)
                {
                    try
                    {
                        _messagesManager.Dispose();
                    }
                    catch (Exception)
                    {

                    }

                    _messagesManager = null;
                }

                if (_bandwidthLimit != null)
                {
                    try
                    {
                        _bandwidthLimit.Dispose();
                    }
                    catch (Exception)
                    {

                    }

                    _bandwidthLimit = null;
                }
            }
        }
예제 #13
0
        //#endif
        public ConnectionsManager(ClientManager clientManager, ServerManager serverManager, CacheManager cacheManager, BufferManager bufferManager)
        {
            _clientManager = clientManager;
            _serverManager = serverManager;
            _cacheManager = cacheManager;
            _bufferManager = bufferManager;

            _settings = new Settings(this.ThisLock);

            _routeTable = new Kademlia<Node>(512, 20);

            _connectionManagers = new LockedList<ConnectionManager>();

            _messagesManager = new MessagesManager();
            _messagesManager.GetLockNodesEvent = (object sender) =>
            {
                lock (this.ThisLock)
                {
                    return _connectionManagers.Select(n => n.Node).ToArray();
                }
            };

            _creatingNodes = new LockedList<Node>();

            _waitingNodes = new VolatileHashSet<Node>(new TimeSpan(0, 0, 30));
            _cuttingNodes = new VolatileHashSet<Node>(new TimeSpan(0, 10, 0));
            _removeNodes = new VolatileHashSet<Node>(new TimeSpan(0, 30, 0));

            _succeededUris = new VolatileHashSet<string>(new TimeSpan(1, 0, 0));

            _downloadBlocks = new VolatileHashSet<Key>(new TimeSpan(0, 30, 0));
            _pushBroadcastSignaturesRequestList = new VolatileHashSet<string>(new TimeSpan(0, 3, 0));
            _pushUnicastSignaturesRequestList = new VolatileHashSet<string>(new TimeSpan(0, 3, 0));
            _pushMulticastWikisRequestList = new VolatileHashSet<Wiki>(new TimeSpan(0, 3, 0));
            _pushMulticastChatsRequestList = new VolatileHashSet<Chat>(new TimeSpan(0, 3, 0));

            _relayBlocks = new VolatileHashSet<Key>(new TimeSpan(0, 30, 0));

            _refreshTimer = new WatchTimer(this.RefreshTimer, new TimeSpan(0, 0, 5));
        }