예제 #1
0
        public void TryStartDownloadDiscovered(Hash packageId)
        {
            var packageDiscovery = packageRegistry.ImmutableDiscoveredPackages.FirstOrDefault(p => p.PackageId.Equals(packageId));

            if (packageDiscovery == null)
            {
                return;
            }

            // try start download
            if (!packageDownloadManager.GetDiscoveredPackageAndStartDownloadPackage(packageDiscovery, out Task startDownloadTask))
            {
                return;
            }

            // create and register task for starting download
            var task = new LongRunningTask(
                $"Starting download of package \"{packageDiscovery.Name}\" {packageDiscovery.PackageId:s}",
                startDownloadTask,
                $"Download has started"
                );

            // register
            tasks.AddTaskToQueue(task);
        }
예제 #2
0
        public void Start(AppInstanceSettings settings)
        {
            if (settings.DownloadEverything)
            {
                PackageRegistry.RemotePackageDiscovered += (package) =>
                {
                    if (PackageDownloadManager.GetDiscoveredPackageAndStartDownloadPackage(package, out var task))
                    {
                        task.Wait();
                    }
                };
            }

            UdpPeerDiscovery.EnableAutoSearch(
                allowListener: settings.EnableUdpDiscoveryListener,
                allowClient: settings.EnableUdpDiscoveryClient
                );

            PackageDownloadManager.RestoreUnfinishedDownloads();
        }