From 516f35fb9375d77ba776dbc3de36cbf47b353837 Mon Sep 17 00:00:00 2001 From: MrBBBaiXue Date: Wed, 20 Nov 2024 17:33:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ra3.BattleNet.Downloader/Download.cs | 14 +++++++++----- .../Ra3.BattleNet.Downloader.csproj | 8 ++++---- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Ra3.BattleNet.Downloader/Download.cs b/Ra3.BattleNet.Downloader/Download.cs index 38de5a9..6d97def 100644 --- a/Ra3.BattleNet.Downloader/Download.cs +++ b/Ra3.BattleNet.Downloader/Download.cs @@ -5,10 +5,12 @@ using System.Diagnostics; using System.IO; using System.Linq; +using System.Net; using System.Reflection; using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; +using System.Windows.Controls; using System.Windows.Threading; namespace Ra3.BattleNet.Downloader; @@ -38,11 +40,13 @@ public static async Task BitTorrentDownload(ViewModel viewModel) var settingsBuilder = new EngineSettingsBuilder { - ListenPort = -1, - DhtPort = -1, AllowPortForwarding = false, CacheDirectory = cacheFolder, + DhtEndPoint = null }; + + settingsBuilder.ListenEndPoints.Add(IPAddress.Loopback.ToString(), new IPEndPoint(IPAddress.Loopback, 0)); + var engine = new ClientEngine(settingsBuilder.ToSettings()); var taskSource = new TaskCompletionSource(); @@ -59,10 +63,10 @@ public static async Task BitTorrentDownload(ViewModel viewModel) if (!torrentManager.Complete) { var monitor = torrentManager.Monitor; - viewModel.SetDownloadedSize(monitor.DataBytesDownloaded, torrent.Size); - var progress = (double)monitor.DataBytesDownloaded / torrent.Size; + viewModel.SetDownloadedSize(monitor.DataBytesReceived, torrent.Size); + var progress = (double)monitor.DataBytesReceived / torrent.Size; viewModel.SetProgress(progress); - viewModel.SetDownloadSpeed(monitor.DownloadSpeed); + viewModel.SetDownloadSpeed(monitor.DownloadRate); return; } diff --git a/Ra3.BattleNet.Downloader/Ra3.BattleNet.Downloader.csproj b/Ra3.BattleNet.Downloader/Ra3.BattleNet.Downloader.csproj index 29a9e77..cd41310 100644 --- a/Ra3.BattleNet.Downloader/Ra3.BattleNet.Downloader.csproj +++ b/Ra3.BattleNet.Downloader/Ra3.BattleNet.Downloader.csproj @@ -30,13 +30,13 @@ all - runtime; build; native; contentfiles; analyzers; buildtransitive - + all - runtime; build; native; contentfiles; analyzers; buildtransitive - + + +