mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-02 05:43:40 +01:00
Add Happy Eyeballs Support (#1187)
This commit is contained in:
parent
2e2ce241e2
commit
6a0b4e5ad7
11 changed files with 271 additions and 18 deletions
|
|
@ -3,13 +3,13 @@ using System.Collections.Generic;
|
|||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Dalamud.Configuration.Internal;
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.Windowing;
|
||||
using Dalamud.Networking.Http;
|
||||
using ImGuiNET;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ public class BranchSwitcherWindow : Window
|
|||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
using var client = new HttpClient();
|
||||
var client = Service<HappyHttpClient>.Get().SharedHttpClient;
|
||||
this.branches = await client.GetFromJsonAsync<Dictionary<string, VersionEntry>>(BranchInfoUrl);
|
||||
Debug.Assert(this.branches != null, "this.branches != null");
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ using System.Threading;
|
|||
using System.Threading.Tasks;
|
||||
|
||||
using Dalamud.Game;
|
||||
using Dalamud.Networking.Http;
|
||||
using Dalamud.Plugin.Internal;
|
||||
using Dalamud.Plugin.Internal.Types;
|
||||
using Dalamud.Utility;
|
||||
|
|
@ -48,6 +49,9 @@ internal class PluginImageCache : IDisposable, IServiceType
|
|||
[ServiceManager.ServiceDependency]
|
||||
private readonly InterfaceManager.InterfaceManagerWithScene imWithScene = Service<InterfaceManager.InterfaceManagerWithScene>.Get();
|
||||
|
||||
[ServiceManager.ServiceDependency]
|
||||
private readonly HappyHttpClient happyHttpClient = Service<HappyHttpClient>.Get();
|
||||
|
||||
private readonly BlockingCollection<Tuple<ulong, Func<Task>>> downloadQueue = new();
|
||||
private readonly BlockingCollection<Func<Task>> loadQueue = new();
|
||||
private readonly CancellationTokenSource cancelToken = new();
|
||||
|
|
@ -535,7 +539,7 @@ internal class PluginImageCache : IDisposable, IServiceType
|
|||
var bytes = await this.RunInDownloadQueue<byte[]?>(
|
||||
async () =>
|
||||
{
|
||||
var data = await Util.HttpClient.GetAsync(url);
|
||||
var data = await this.happyHttpClient.SharedHttpClient.GetAsync(url);
|
||||
if (data.StatusCode == HttpStatusCode.NotFound)
|
||||
return null;
|
||||
|
||||
|
|
@ -627,7 +631,9 @@ internal class PluginImageCache : IDisposable, IServiceType
|
|||
var bytes = await this.RunInDownloadQueue<byte[]?>(
|
||||
async () =>
|
||||
{
|
||||
var data = await Util.HttpClient.GetAsync(url);
|
||||
var httpClient = Service<HappyHttpClient>.Get().SharedHttpClient;
|
||||
|
||||
var data = await httpClient.GetAsync(url);
|
||||
if (data.StatusCode == HttpStatusCode.NotFound)
|
||||
return null;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,11 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Dalamud.Networking.Http;
|
||||
using Dalamud.Plugin.Internal;
|
||||
using Dalamud.Utility;
|
||||
using Serilog;
|
||||
|
||||
namespace Dalamud.Interface.Internal.Windows.PluginInstaller;
|
||||
|
||||
|
|
@ -42,7 +39,7 @@ internal class DalamudChangelogManager
|
|||
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
|
||||
public async Task ReloadChangelogAsync()
|
||||
{
|
||||
using var client = new HttpClient();
|
||||
var client = Service<HappyHttpClient>.Get().SharedHttpClient;
|
||||
this.Changelogs = null;
|
||||
|
||||
var dalamudChangelogs = await client.GetFromJsonAsync<List<DalamudChangelog>>(DalamudChangelogUrl);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue