Ejemplo n.º 1
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         WebServer?.Dispose();
         WebServer = null;
         nodeDiscovery?.Dispose();
         nodeDiscovery = null;
         httpclient?.Dispose();
         httpclient = null;
     }
 }
Ejemplo n.º 2
0
        public PCLocalService(IConfigStorage configStorage, ILoggerFactory logfac, VirtualFileSystem fileSystem, string extraWebPath)
        {
            ExtraWebPath = extraWebPath;

            ConfigStorage = configStorage;
            FileSystem    = fileSystem;
            loggerFactory = logfac;
#pragma warning disable CA1062 // Validate arguments of public methods
            logger = loggerFactory.CreateLogger("PCLocalService");
#pragma warning restore CA1062 // Validate arguments of public methods

            KnownNodes                 = new Dictionary <string, NodeInfo>();
            sharedPCs                  = new List <NodeShareInfo>();
            httpclient                 = new HttpClient();
            httpclient.Timeout         = TimeSpan.FromSeconds(10);
            nodeDiscovery              = new NodeDiscovery(logfac);
            nodeDiscovery.OnNodeAdded += NodeDiscovery_OnNodeAdded;
            nodeDiscovery.OnError     += (o, e) => OnError?.Invoke(this, new ServiceErrorEventArgs(e));
            fetchQueue                 = new List <FetchQueueItem>();

            var cfg = LoadConfiguration();
            ServerPort = cfg.Port;
#pragma warning disable CA1305 // Specify IFormatProvider
            NodeId = cfg.Id.ToString("N");
#pragma warning restore CA1305 // Specify IFormatProvider

            LoadPCList();
            foreach (var item in _PersonalClouds)
            {
                item.ResyncClientList();
            }
            fetchCloudInfo = new ActionBlock <NodeInfo>(GetNodeClodeInfo, new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = 3
            });
            InitWebServer();
        }