From 8703c3a5985c9c0d03d856843e78ed7c0713db1f Mon Sep 17 00:00:00 2001
From: Lightczx <1686188646@qq.com>
Date: Tue, 16 Apr 2024 17:28:15 +0800
Subject: [PATCH] init
---
.../Snap.Hutao/Web/Enka/EnkaClient.cs | 68 ++++++++-----------
.../Annotation/ApiInformationAttribute.cs | 1 +
.../Web/Hoyolab/App/Account/AccountClient.cs | 15 +---
.../Web/Hoyolab/Bbs/User/UserClient.cs | 13 +---
.../Web/Hoyolab/Bbs/User/UserClientOversea.cs | 10 ---
.../Common/Announcement/AnnouncementClient.cs | 23 +------
.../Hk4e/Event/GachaInfo/GachaInfoClient.cs | 4 +-
.../Web/Hoyolab/Hk4e/Sdk/Combo/PandaClient.cs | 6 +-
.../Web/Hoyolab/Passport/PassportClient.cs | 23 +------
.../Web/Hoyolab/Passport/PassportClient2.cs | 25 ++-----
.../Hoyolab/Passport/PassportClientOversea.cs | 23 +------
.../PublicData/DeviceFp/DeviceFpClient.cs | 4 +-
.../SdkStatic/Hk4e/Launcher/ResourceClient.cs | 17 +----
.../Web/Hoyolab/Takumi/Auth/AuthClient.cs | 17 +----
.../Hoyolab/Takumi/Binding/BindingClient.cs | 32 ++-------
.../Hoyolab/Takumi/Binding/BindingClient2.cs | 25 +------
.../Event/BbsSignReward/SignInClient.cs | 19 +++---
.../BbsSignReward/SignInClientOversea.cs | 13 ++--
.../Takumi/Event/Calculate/CalculateClient.cs | 50 ++------------
.../Takumi/GameRecord/GameRecordClient.cs | 48 +++----------
20 files changed, 95 insertions(+), 341 deletions(-)
diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Enka/EnkaClient.cs b/src/Snap.Hutao/Snap.Hutao/Web/Enka/EnkaClient.cs
index 7290ebc3..2ba8423a 100644
--- a/src/Snap.Hutao/Snap.Hutao/Web/Enka/EnkaClient.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Web/Enka/EnkaClient.cs
@@ -15,9 +15,6 @@ using System.Net.Sockets;
namespace Snap.Hutao.Web.Enka;
-///
-/// Enka API 客户端
-///
[HighQuality]
[ConstructorGenerated(ResolveHttpClient = true)]
[HttpClient(HttpClientConfiguration.Default)]
@@ -26,26 +23,14 @@ internal sealed partial class EnkaClient
private const string EnkaAPI = "https://enka.network/api/uid/{0}";
private readonly IHttpRequestMessageBuilderFactory httpRequestMessageBuilderFactory;
+ private readonly IHttpClientFactory httpClientFactory;
private readonly JsonSerializerOptions options;
- private readonly HttpClient httpClient;
- ///
- /// 异步获取转发的 Enka API 响应
- ///
- /// 玩家Uid
- /// 取消令牌
- /// Enka API 响应
public ValueTask GetForwardDataAsync(in PlayerUid playerUid, CancellationToken token = default)
{
return TryGetEnkaResponseCoreAsync(HutaoEndpoints.Enka(playerUid), token);
}
- ///
- /// 异步获取 Enka API 响应
- ///
- /// 玩家Uid
- /// 取消令牌
- /// Enka API 响应
public ValueTask GetDataAsync(in PlayerUid playerUid, CancellationToken token = default)
{
return TryGetEnkaResponseCoreAsync(string.Format(CultureInfo.CurrentCulture, EnkaAPI, playerUid), token);
@@ -59,34 +44,37 @@ internal sealed partial class EnkaClient
.SetRequestUri(url)
.Get();
- using (HttpResponseMessage response = await httpClient.SendAsync(builder.HttpRequestMessage, HttpCompletionOption.ResponseHeadersRead, token).ConfigureAwait(false))
+ using (HttpClient httpClient = httpClientFactory.CreateClient(nameof(EnkaClient)))
{
- if (response.IsSuccessStatusCode)
+ using (HttpResponseMessage response = await httpClient.SendAsync(builder.HttpRequestMessage, HttpCompletionOption.ResponseHeadersRead, token).ConfigureAwait(false))
{
- return await response.Content.ReadFromJsonAsync(options, token).ConfigureAwait(false);
- }
- else
- {
- // https://github.com/yoimiya-kokomi/miao-plugin/pull/441
- // Additionally, HTTP codes for UID requests:
- // 400 = wrong UID format
- // 404 = player does not exist(MHY server told that)
- // 429 = rate - limit
- // 424 = game maintenance / everything is broken after the update
- // 500 = general server error
- // 503 = I screwed up massively
- string message = response.StatusCode switch
+ if (response.IsSuccessStatusCode)
{
- HttpStatusCode.BadRequest => SH.WebEnkaResponseStatusCode400,
- HttpStatusCode.NotFound => SH.WebEnkaResponseStatusCode404,
- HttpStatusCode.FailedDependency => SH.WebEnkaResponseStatusCode424,
- HttpStatusCode.TooManyRequests => SH.WebEnkaResponseStatusCode429,
- HttpStatusCode.InternalServerError => SH.WebEnkaResponseStatusCode500,
- HttpStatusCode.ServiceUnavailable => SH.WebEnkaResponseStatusCode503,
- _ => SH.WebEnkaResponseStatusCodeUnknown,
- };
+ return await response.Content.ReadFromJsonAsync(options, token).ConfigureAwait(false);
+ }
+ else
+ {
+ // https://github.com/yoimiya-kokomi/miao-plugin/pull/441
+ // Additionally, HTTP codes for UID requests:
+ // 400 = wrong UID format
+ // 404 = player does not exist(MHY server told that)
+ // 429 = rate - limit
+ // 424 = game maintenance / everything is broken after the update
+ // 500 = general server error
+ // 503 = I screwed up massively
+ string message = response.StatusCode switch
+ {
+ HttpStatusCode.BadRequest => SH.WebEnkaResponseStatusCode400,
+ HttpStatusCode.NotFound => SH.WebEnkaResponseStatusCode404,
+ HttpStatusCode.FailedDependency => SH.WebEnkaResponseStatusCode424,
+ HttpStatusCode.TooManyRequests => SH.WebEnkaResponseStatusCode429,
+ HttpStatusCode.InternalServerError => SH.WebEnkaResponseStatusCode500,
+ HttpStatusCode.ServiceUnavailable => SH.WebEnkaResponseStatusCode503,
+ _ => SH.WebEnkaResponseStatusCodeUnknown,
+ };
- return new() { Message = message, };
+ return new() { Message = message, };
+ }
}
}
}
diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Annotation/ApiInformationAttribute.cs b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Annotation/ApiInformationAttribute.cs
index 83a7fa01..d7af5b86 100644
--- a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Annotation/ApiInformationAttribute.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Annotation/ApiInformationAttribute.cs
@@ -10,6 +10,7 @@ namespace Snap.Hutao.Web.Hoyolab.Annotation;
/// 指示此API 已经经过验证,且明确其调用
///
[AttributeUsage(AttributeTargets.Method)]
+[Obsolete("不再使用此特性")]
internal sealed class ApiInformationAttribute : Attribute
{
///
diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/App/Account/AccountClient.cs b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/App/Account/AccountClient.cs
index 2e7f3b89..af1c112b 100644
--- a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/App/Account/AccountClient.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/App/Account/AccountClient.cs
@@ -13,26 +13,15 @@ using System.Net.Http;
namespace Snap.Hutao.Web.Hoyolab.App.Account;
-///
-/// 账户客户端
-///
[HighQuality]
[ConstructorGenerated(ResolveHttpClient = true)]
[HttpClient(HttpClientConfiguration.XRpc)]
internal sealed partial class AccountClient
{
private readonly IHttpRequestMessageBuilderFactory httpRequestMessageBuilderFactory;
+ private readonly IHttpClientFactory httpClientFactory;
private readonly ILogger logger;
- private readonly HttpClient httpClient;
- ///
- /// 异步生成米游社操作验证密钥
- ///
- /// 用户
- /// 提交数据
- /// 取消令牌
- /// 用户角色信息
- [ApiInformation(Cookie = CookieType.SToken, Salt = SaltType.K2)]
public async ValueTask> GenerateAuthenticationKeyAsync(User user, GenAuthKeyData data, CancellationToken token = default)
{
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
@@ -44,7 +33,7 @@ internal sealed partial class AccountClient
await builder.SignDataAsync(DataSignAlgorithmVersion.Gen1, SaltType.K2, false).ConfigureAwait(false);
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(AccountClient)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Bbs/User/UserClient.cs b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Bbs/User/UserClient.cs
index f13416d8..38dbcc9b 100644
--- a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Bbs/User/UserClient.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Bbs/User/UserClient.cs
@@ -9,24 +9,15 @@ using System.Net.Http;
namespace Snap.Hutao.Web.Hoyolab.Bbs.User;
-///
-/// 用户信息客户端 DS版
-///
[HighQuality]
[ConstructorGenerated(ResolveHttpClient = true)]
[HttpClient(HttpClientConfiguration.XRpc)]
internal sealed partial class UserClient : IUserClient
{
private readonly IHttpRequestMessageBuilderFactory httpRequestMessageBuilderFactory;
+ private readonly IHttpClientFactory httpClientFactory;
private readonly ILogger logger;
- private readonly HttpClient httpClient;
- ///
- /// 获取当前用户详细信息
- ///
- /// 用户
- /// 取消令牌
- /// 详细信息
public async ValueTask> GetUserFullInfoAsync(Model.Entity.User user, CancellationToken token = default)
{
ArgumentException.ThrowIfNullOrEmpty(user.Aid);
@@ -37,7 +28,7 @@ internal sealed partial class UserClient : IUserClient
.Get();
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(UserClient)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Bbs/User/UserClientOversea.cs b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Bbs/User/UserClientOversea.cs
index ac719dfc..3e5604eb 100644
--- a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Bbs/User/UserClientOversea.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Bbs/User/UserClientOversea.cs
@@ -10,9 +10,6 @@ using System.Net.Http;
namespace Snap.Hutao.Web.Hoyolab.Bbs.User;
-///
-/// 用户信息客户端 Hoyolab版
-///
[ConstructorGenerated(ResolveHttpClient = true)]
[HttpClient(HttpClientConfiguration.Default)]
internal sealed partial class UserClientOversea : IUserClient
@@ -21,13 +18,6 @@ internal sealed partial class UserClientOversea : IUserClient
private readonly ILogger logger;
private readonly HttpClient httpClient;
- ///
- /// 获取当前用户详细信息,使用 LToken
- ///
- /// 用户
- /// 取消令牌
- /// 详细信息
- [ApiInformation(Cookie = CookieType.LToken)]
public async ValueTask> GetUserFullInfoAsync(Model.Entity.User user, CancellationToken token = default)
{
ArgumentException.ThrowIfNullOrEmpty(user.Aid);
diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Hk4e/Common/Announcement/AnnouncementClient.cs b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Hk4e/Common/Announcement/AnnouncementClient.cs
index 9f467c37..e6d4f15f 100644
--- a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Hk4e/Common/Announcement/AnnouncementClient.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Hk4e/Common/Announcement/AnnouncementClient.cs
@@ -9,24 +9,14 @@ using System.Net.Http;
namespace Snap.Hutao.Web.Hoyolab.Hk4e.Common.Announcement;
-///
-/// 公告客户端
-///
[ConstructorGenerated(ResolveHttpClient = true)]
[HttpClient(HttpClientConfiguration.Default)]
internal sealed partial class AnnouncementClient
{
private readonly IHttpRequestMessageBuilderFactory httpRequestMessageBuilderFactory;
+ private readonly IHttpClientFactory httpClientFactory;
private readonly ILogger logger;
- private readonly HttpClient httpClient;
- ///
- /// 异步获取公告列表
- ///
- /// 语言代码
- /// 服务器
- /// 取消令牌
- /// 公告列表
public async ValueTask> GetAnnouncementsAsync(string languageCode, Region region, CancellationToken token = default)
{
string annListUrl = region.IsOversea()
@@ -38,19 +28,12 @@ internal sealed partial class AnnouncementClient
.Get();
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(AnnouncementClient)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
}
- ///
- /// 异步获取公告内容列表
- ///
- /// 语言代码
- /// 服务器
- /// 取消令牌
- /// 公告内容列表
public async ValueTask>> GetAnnouncementContentsAsync(string languageCode, Region region, CancellationToken token = default)
{
string annContentUrl = region.IsOversea()
@@ -62,7 +45,7 @@ internal sealed partial class AnnouncementClient
.Get();
Response>? resp = await builder
- .TryCatchSendAsync>>(httpClient, logger, token)
+ .TryCatchSendAsync>>(httpClientFactory.CreateClient(nameof(AnnouncementClient)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Hk4e/Event/GachaInfo/GachaInfoClient.cs b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Hk4e/Event/GachaInfo/GachaInfoClient.cs
index f3563721..f3b87e75 100644
--- a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Hk4e/Event/GachaInfo/GachaInfoClient.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Hk4e/Event/GachaInfo/GachaInfoClient.cs
@@ -18,8 +18,8 @@ namespace Snap.Hutao.Web.Hoyolab.Hk4e.Event.GachaInfo;
internal sealed partial class GachaInfoClient
{
private readonly IHttpRequestMessageBuilderFactory httpRequestMessageBuilderFactory;
+ private readonly IHttpClientFactory httpClientFactory;
private readonly ILogger logger;
- private readonly HttpClient httpClient;
///
/// 获取记录页面
@@ -40,7 +40,7 @@ internal sealed partial class GachaInfoClient
.Get();
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(GachaInfoClient)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Hk4e/Sdk/Combo/PandaClient.cs b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Hk4e/Sdk/Combo/PandaClient.cs
index c9295ecc..fe30bb9a 100644
--- a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Hk4e/Sdk/Combo/PandaClient.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Hk4e/Sdk/Combo/PandaClient.cs
@@ -14,8 +14,8 @@ namespace Snap.Hutao.Web.Hoyolab.Hk4e.Sdk.Combo;
internal sealed partial class PandaClient
{
private readonly IHttpRequestMessageBuilderFactory httpRequestMessageBuilderFactory;
+ private readonly IHttpClientFactory httpClientFactory;
private readonly ILogger logger;
- private readonly HttpClient httpClient;
public async ValueTask> QRCodeFetchAsync(CancellationToken token = default)
{
@@ -28,7 +28,7 @@ internal sealed partial class PandaClient
.PostJson(options);
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(PandaClient)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
@@ -44,7 +44,7 @@ internal sealed partial class PandaClient
.PostJson(options);
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(PandaClient)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Passport/PassportClient.cs b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Passport/PassportClient.cs
index 8f98219d..82eed2d8 100644
--- a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Passport/PassportClient.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Passport/PassportClient.cs
@@ -12,25 +12,15 @@ using System.Net.Http;
namespace Snap.Hutao.Web.Hoyolab.Passport;
-///
-/// 通行证客户端 XRPC 版
-///
[HighQuality]
[ConstructorGenerated(ResolveHttpClient = true)]
[HttpClient(HttpClientConfiguration.XRpc2)]
internal sealed partial class PassportClient : IPassportClient
{
private readonly IHttpRequestMessageBuilderFactory httpRequestMessageBuilderFactory;
+ private readonly IHttpClientFactory httpClientFactory;
private readonly ILogger logger;
- private readonly HttpClient httpClient;
- ///
- /// 异步获取 CookieToken
- ///
- /// 用户
- /// 取消令牌
- /// cookie token
- [ApiInformation(Cookie = CookieType.SToken, Salt = SaltType.PROD)]
public async ValueTask> GetCookieAccountInfoBySTokenAsync(User user, CancellationToken token = default)
{
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
@@ -41,19 +31,12 @@ internal sealed partial class PassportClient : IPassportClient
await builder.SignDataAsync(DataSignAlgorithmVersion.Gen2, SaltType.PROD, true).ConfigureAwait(false);
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(PassportClient)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
}
- ///
- /// 异步获取 LToken
- ///
- /// 用户
- /// 取消令牌
- /// uid 与 cookie token
- [ApiInformation(Cookie = CookieType.SToken, Salt = SaltType.PROD)]
public async ValueTask> GetLTokenBySTokenAsync(User user, CancellationToken token = default)
{
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
@@ -64,7 +47,7 @@ internal sealed partial class PassportClient : IPassportClient
await builder.SignDataAsync(DataSignAlgorithmVersion.Gen2, SaltType.PROD, true).ConfigureAwait(false);
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(PassportClient)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Passport/PassportClient2.cs b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Passport/PassportClient2.cs
index ebe956ec..43056df2 100644
--- a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Passport/PassportClient2.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Passport/PassportClient2.cs
@@ -13,25 +13,15 @@ using System.Net.Http;
namespace Snap.Hutao.Web.Hoyolab.Passport;
-///
-/// 通行证客户端
-///
[HighQuality]
[ConstructorGenerated(ResolveHttpClient = true)]
[HttpClient(HttpClientConfiguration.XRpc2)]
internal sealed partial class PassportClient2
{
private readonly IHttpRequestMessageBuilderFactory httpRequestMessageBuilderFactory;
+ private readonly IHttpClientFactory httpClientFactory;
private readonly ILogger logger;
- private readonly HttpClient httpClient;
- ///
- /// 异步验证 LToken
- ///
- /// 用户
- /// 取消令牌
- /// 验证信息
- [ApiInformation(Cookie = CookieType.LToken)]
public async ValueTask> VerifyLtokenAsync(User user, CancellationToken token)
{
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
@@ -40,19 +30,12 @@ internal sealed partial class PassportClient2
.PostJson(new Timestamp());
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(PassportClient2)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
}
- ///
- /// V1 SToken 登录
- ///
- /// v1 SToken
- /// 取消令牌
- /// 登录数据
- [ApiInformation(Salt = SaltType.PROD)]
public async ValueTask> LoginBySTokenAsync(Cookie stokenV1, CancellationToken token = default)
{
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
@@ -63,7 +46,7 @@ internal sealed partial class PassportClient2
await builder.SignDataAsync(DataSignAlgorithmVersion.Gen2, SaltType.PROD, true).ConfigureAwait(false);
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(PassportClient2)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
@@ -83,7 +66,7 @@ internal sealed partial class PassportClient2
.PostJson(data);
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(PassportClient2)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Passport/PassportClientOversea.cs b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Passport/PassportClientOversea.cs
index 2f4a1ac8..e34f57f1 100644
--- a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Passport/PassportClientOversea.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Passport/PassportClientOversea.cs
@@ -11,24 +11,14 @@ using System.Net.Http;
namespace Snap.Hutao.Web.Hoyolab.Passport;
-///
-/// 通行证客户端 XRPC 版
-///
[ConstructorGenerated(ResolveHttpClient = true)]
[HttpClient(HttpClientConfiguration.XRpc3)]
internal sealed partial class PassportClientOversea : IPassportClient
{
private readonly IHttpRequestMessageBuilderFactory httpRequestMessageBuilderFactory;
private readonly ILogger logger;
- private readonly HttpClient httpClient;
+ private readonly IHttpClientFactory httpClientFactory;
- ///
- /// 异步获取 CookieToken
- ///
- /// 用户
- /// 取消令牌
- /// cookie token
- [ApiInformation(Cookie = CookieType.SToken)]
public async ValueTask> GetCookieAccountInfoBySTokenAsync(User user, CancellationToken token = default)
{
string? stoken = user.SToken?.GetValueOrDefault(Cookie.STOKEN);
@@ -42,19 +32,12 @@ internal sealed partial class PassportClientOversea : IPassportClient
.PostJson(data);
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(PassportClientOversea)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
}
- ///
- /// 异步获取 LToken
- ///
- /// 用户
- /// 取消令牌
- /// uid 与 cookie token
- [ApiInformation(Cookie = CookieType.SToken)]
public async ValueTask> GetLTokenBySTokenAsync(User user, CancellationToken token = default)
{
string? stoken = user.SToken?.GetValueOrDefault(Cookie.STOKEN);
@@ -68,7 +51,7 @@ internal sealed partial class PassportClientOversea : IPassportClient
.PostJson(data);
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(PassportClientOversea)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/PublicData/DeviceFp/DeviceFpClient.cs b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/PublicData/DeviceFp/DeviceFpClient.cs
index 0b27db4a..9e834b46 100644
--- a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/PublicData/DeviceFp/DeviceFpClient.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/PublicData/DeviceFp/DeviceFpClient.cs
@@ -14,7 +14,7 @@ namespace Snap.Hutao.Web.Hoyolab.PublicData.DeviceFp;
internal sealed partial class DeviceFpClient
{
private readonly IHttpRequestMessageBuilderFactory httpRequestMessageBuilderFactory;
- private readonly HttpClient httpClient;
+ private readonly IHttpClientFactory httpClientFactory;
private readonly ILogger logger;
public async ValueTask> GetFingerprintAsync(DeviceFpData data, CancellationToken token)
@@ -24,7 +24,7 @@ internal sealed partial class DeviceFpClient
.PostJson(data);
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(DeviceFpClient)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/SdkStatic/Hk4e/Launcher/ResourceClient.cs b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/SdkStatic/Hk4e/Launcher/ResourceClient.cs
index ca3cc16f..e3ef9d01 100644
--- a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/SdkStatic/Hk4e/Launcher/ResourceClient.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/SdkStatic/Hk4e/Launcher/ResourceClient.cs
@@ -8,30 +8,19 @@ using Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Resource;
using Snap.Hutao.Web.Request.Builder;
using Snap.Hutao.Web.Request.Builder.Abstraction;
using Snap.Hutao.Web.Response;
-using System.IO;
using System.Net.Http;
-using System.Text;
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher;
-///
-/// 游戏资源客户端
-///
[HighQuality]
[ConstructorGenerated(ResolveHttpClient = true)]
[HttpClient(HttpClientConfiguration.Default)]
internal sealed partial class ResourceClient
{
private readonly IHttpRequestMessageBuilderFactory httpRequestMessageBuilderFactory;
- private readonly HttpClient httpClient;
+ private readonly IHttpClientFactory httpClientFactory;
private readonly ILogger logger;
- ///
- /// 异步获取游戏资源
- ///
- /// 方案
- /// 取消令牌
- /// 游戏资源
public async ValueTask> GetResourceAsync(LaunchScheme scheme, CancellationToken token = default)
{
string url = scheme.IsOversea
@@ -43,7 +32,7 @@ internal sealed partial class ResourceClient
.Get();
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(ResourceClient)), logger, token)
.ConfigureAwait(false);
// 最新版完整包
@@ -72,7 +61,7 @@ internal sealed partial class ResourceClient
.Get();
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(ResourceClient)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/Auth/AuthClient.cs b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/Auth/AuthClient.cs
index 50820381..79d287f0 100644
--- a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/Auth/AuthClient.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/Auth/AuthClient.cs
@@ -13,19 +13,15 @@ using System.Net.Http;
namespace Snap.Hutao.Web.Hoyolab.Takumi.Auth;
-///
-/// 授权客户端
-///
[HighQuality]
[ConstructorGenerated(ResolveHttpClient = true)]
[HttpClient(HttpClientConfiguration.Default)]
internal sealed partial class AuthClient
{
private readonly IHttpRequestMessageBuilderFactory httpRequestMessageBuilderFactory;
+ private readonly IHttpClientFactory httpClientFactory;
private readonly ILogger logger;
- private readonly HttpClient httpClient;
- [ApiInformation(Cookie = CookieType.SToken, Salt = SaltType.K2)]
public async ValueTask> GetActionTicketBySTokenAsync(string action, User user, CancellationToken token = default)
{
ArgumentException.ThrowIfNullOrEmpty(user.Aid);
@@ -39,19 +35,12 @@ internal sealed partial class AuthClient
await builder.SignDataAsync(DataSignAlgorithmVersion.Gen1, SaltType.K2, true).ConfigureAwait(false);
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(AuthClient)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
}
- ///
- /// 获取 MultiToken
- ///
- /// login cookie
- /// 是否为国际服
- /// 取消令牌
- /// 包含token的字典
public async ValueTask>> GetMultiTokenByLoginTicketAsync(Cookie cookie, bool isOversea, CancellationToken token = default)
{
Response>? resp = null;
@@ -69,7 +58,7 @@ internal sealed partial class AuthClient
.Get();
resp = await builder
- .TryCatchSendAsync>>(httpClient, logger, token)
+ .TryCatchSendAsync>>(httpClientFactory.CreateClient(nameof(AuthClient)), logger, token)
.ConfigureAwait(false);
}
diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/Binding/BindingClient.cs b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/Binding/BindingClient.cs
index c02f6736..5a449b87 100644
--- a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/Binding/BindingClient.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/Binding/BindingClient.cs
@@ -1,6 +1,7 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
+using Microsoft.Extensions.Http;
using Snap.Hutao.Core.DependencyInjection.Annotation.HttpClient;
using Snap.Hutao.Model.Entity;
using Snap.Hutao.Web.Hoyolab.Annotation;
@@ -12,26 +13,16 @@ using System.Net.Http;
namespace Snap.Hutao.Web.Hoyolab.Takumi.Binding;
-///
-/// 绑定客户端
-///
[HighQuality]
[ConstructorGenerated(ResolveHttpClient = true)]
[HttpClient(HttpClientConfiguration.Default)]
internal sealed partial class BindingClient
{
private readonly IHttpRequestMessageBuilderFactory httpRequestMessageBuilderFactory;
+ private readonly IHttpClientFactory httpClientFactory;
private readonly IServiceProvider serviceProvider;
private readonly ILogger logger;
- private readonly HttpClient httpClient;
- ///
- /// 异步获取用户角色信息
- /// 自动判断是否为国际服
- ///
- /// 用户
- /// 取消令牌
- /// 用户角色信息
public async ValueTask>> GetUserGameRolesOverseaAwareAsync(User user, CancellationToken token = default)
{
if (user.IsOversea)
@@ -55,14 +46,6 @@ internal sealed partial class BindingClient
}
}
- ///
- /// 异步获取用户角色信息
- ///
- /// 操作凭证
- /// 用户
- /// 取消令牌
- /// 用户角色信息
- [ApiInformation(Cookie = CookieType.LToken)]
public async ValueTask>> GetUserGameRolesByActionTicketAsync(string actionTicket, User user, CancellationToken token = default)
{
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
@@ -71,19 +54,12 @@ internal sealed partial class BindingClient
.Get();
Response>? resp = await builder
- .TryCatchSendAsync>>(httpClient, logger, token)
+ .TryCatchSendAsync>>(httpClientFactory.CreateClient(nameof(BindingClient)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
}
- ///
- /// 异步获取国际服用户角色信息
- ///
- /// 用户
- /// 取消令牌
- /// 用户角色信息
- [ApiInformation(Cookie = CookieType.LToken)]
public async ValueTask>> GetOverseaUserGameRolesByCookieAsync(User user, CancellationToken token = default)
{
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
@@ -92,7 +68,7 @@ internal sealed partial class BindingClient
.Get();
Response>? resp = await builder
- .TryCatchSendAsync>>(httpClient, logger, token)
+ .TryCatchSendAsync>>(httpClientFactory.CreateClient(nameof(BindingClient)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/Binding/BindingClient2.cs b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/Binding/BindingClient2.cs
index fdf4232a..2c822950 100644
--- a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/Binding/BindingClient2.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/Binding/BindingClient2.cs
@@ -12,9 +12,6 @@ using System.Net.Http;
namespace Snap.Hutao.Web.Hoyolab.Takumi.Binding;
-///
-/// SToken绑定客户端
-///
[HighQuality]
[ConstructorGenerated(ResolveHttpClient = true)]
[HttpClient(HttpClientConfiguration.XRpc)]
@@ -22,16 +19,9 @@ namespace Snap.Hutao.Web.Hoyolab.Takumi.Binding;
internal sealed partial class BindingClient2
{
private readonly IHttpRequestMessageBuilderFactory httpRequestMessageBuilderFactory;
+ private readonly IHttpClientFactory httpClientFactory;
private readonly ILogger logger;
- private readonly HttpClient httpClient;
- ///
- /// 获取用户角色信息
- ///
- /// 用户
- /// 取消令牌
- /// 用户角色信息
- [ApiInformation(Cookie = CookieType.SToken, Salt = SaltType.LK2)]
public async ValueTask>> GetUserGameRolesBySTokenAsync(User user, CancellationToken token = default)
{
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
@@ -43,21 +33,12 @@ internal sealed partial class BindingClient2
await builder.SignDataAsync(DataSignAlgorithmVersion.Gen1, SaltType.LK2, true).ConfigureAwait(false);
Response>? resp = await builder
- .TryCatchSendAsync>>(httpClient, logger, token)
+ .TryCatchSendAsync>>(httpClientFactory.CreateClient(nameof(BindingClient2)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
}
- ///
- /// 异步生成祈愿验证密钥
- /// 需要 SToken
- ///
- /// 用户
- /// 提交数据
- /// 取消令牌
- /// 用户角色信息
- [ApiInformation(Cookie = CookieType.SToken, Salt = SaltType.LK2)]
public async ValueTask> GenerateAuthenticationKeyAsync(User user, GenAuthKeyData data, CancellationToken token = default)
{
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
@@ -69,7 +50,7 @@ internal sealed partial class BindingClient2
await builder.SignDataAsync(DataSignAlgorithmVersion.Gen1, SaltType.LK2, true).ConfigureAwait(false);
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(BindingClient2)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/Event/BbsSignReward/SignInClient.cs b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/Event/BbsSignReward/SignInClient.cs
index 0a1e2a12..a325e9e6 100644
--- a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/Event/BbsSignReward/SignInClient.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/Event/BbsSignReward/SignInClient.cs
@@ -13,19 +13,16 @@ using System.Net.Http;
namespace Snap.Hutao.Web.Hoyolab.Takumi.Event.BbsSignReward;
-///
-/// 签到客户端
-///
[ConstructorGenerated(ResolveHttpClient = true)]
[HttpClient(HttpClientConfiguration.XRpc)]
[PrimaryHttpMessageHandler(UseCookies = false)]
internal sealed partial class SignInClient : ISignInClient
{
private readonly IHttpRequestMessageBuilderFactory httpRequestMessageBuilderFactory;
+ private readonly IHttpClientFactory httpClientFactory;
private readonly HomaGeetestClient homaGeetestClient;
private readonly CultureOptions cultureOptions;
private readonly ILogger logger;
- private readonly HttpClient httpClient;
public async ValueTask> GetExtraAwardInfoAsync(UserAndUid userAndUid, CancellationToken token = default)
{
@@ -38,7 +35,7 @@ internal sealed partial class SignInClient : ISignInClient
await builder.SignDataAsync(DataSignAlgorithmVersion.Gen1, SaltType.LK2, true).ConfigureAwait(false);
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(SignInClient)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
@@ -55,7 +52,7 @@ internal sealed partial class SignInClient : ISignInClient
await builder.SignDataAsync(DataSignAlgorithmVersion.Gen1, SaltType.LK2, true).ConfigureAwait(false);
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(SignInClient)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
@@ -72,7 +69,7 @@ internal sealed partial class SignInClient : ISignInClient
await builder.SignDataAsync(DataSignAlgorithmVersion.Gen1, SaltType.LK2, true).ConfigureAwait(false);
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(SignInClient)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
@@ -87,7 +84,7 @@ internal sealed partial class SignInClient : ISignInClient
.Get();
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(SignInClient)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
@@ -104,7 +101,7 @@ internal sealed partial class SignInClient : ISignInClient
await builder.SignDataAsync(DataSignAlgorithmVersion.Gen1, SaltType.LK2, true).ConfigureAwait(false);
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(SignInClient)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
@@ -121,7 +118,7 @@ internal sealed partial class SignInClient : ISignInClient
await builder.SignDataAsync(DataSignAlgorithmVersion.Gen1, SaltType.LK2, true).ConfigureAwait(false);
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(SignInClient)), logger, token)
.ConfigureAwait(false);
if (resp is { Data: { Success: 1, Gt: string gt, Challenge: string originChallenge } })
@@ -140,7 +137,7 @@ internal sealed partial class SignInClient : ISignInClient
await verifiedBuilder.SignDataAsync(DataSignAlgorithmVersion.Gen1, SaltType.LK2, true).ConfigureAwait(false);
resp = await verifiedBuilder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(SignInClient)), logger, token)
.ConfigureAwait(false);
}
else
diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/Event/BbsSignReward/SignInClientOversea.cs b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/Event/BbsSignReward/SignInClientOversea.cs
index 03a4ed74..8b180c90 100644
--- a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/Event/BbsSignReward/SignInClientOversea.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/Event/BbsSignReward/SignInClientOversea.cs
@@ -11,18 +11,15 @@ using System.Net.Http;
namespace Snap.Hutao.Web.Hoyolab.Takumi.Event.BbsSignReward;
-///
-/// Global签到客户端
-///
[ConstructorGenerated(ResolveHttpClient = true)]
[HttpClient(HttpClientConfiguration.Default)]
[PrimaryHttpMessageHandler(UseCookies = false)]
internal sealed partial class SignInClientOversea : ISignInClient
{
private readonly IHttpRequestMessageBuilderFactory httpRequestMessageBuilderFactory;
+ private readonly IHttpClientFactory httpClientFactory;
private readonly HomaGeetestClient homaGeetestClient;
private readonly ILogger logger;
- private readonly HttpClient httpClient;
public async ValueTask> GetInfoAsync(UserAndUid userAndUid, CancellationToken token = default(CancellationToken))
{
@@ -32,7 +29,7 @@ internal sealed partial class SignInClientOversea : ISignInClient
.Get();
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(SignInClientOversea)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
@@ -46,7 +43,7 @@ internal sealed partial class SignInClientOversea : ISignInClient
.Get();
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(SignInClientOversea)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
@@ -60,7 +57,7 @@ internal sealed partial class SignInClientOversea : ISignInClient
.PostJson(new SignInData(userAndUid.Uid, true));
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(SignInClientOversea)), logger, token)
.ConfigureAwait(false);
if (resp is { Data: { Success: 1, Gt: string gt, Challenge: string originChallenge } })
@@ -76,7 +73,7 @@ internal sealed partial class SignInClientOversea : ISignInClient
.PostJson(new SignInData(userAndUid.Uid, true));
resp = await verifiedBuilder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(SignInClientOversea)), logger, token)
.ConfigureAwait(false);
}
else
diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/Event/Calculate/CalculateClient.cs b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/Event/Calculate/CalculateClient.cs
index 88257ea7..0f4bc6da 100644
--- a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/Event/Calculate/CalculateClient.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/Event/Calculate/CalculateClient.cs
@@ -11,26 +11,15 @@ using System.Net.Http;
namespace Snap.Hutao.Web.Hoyolab.Takumi.Event.Calculate;
-///
-/// 养成计算器客户端
-///
[HighQuality]
[ConstructorGenerated(ResolveHttpClient = true)]
[HttpClient(HttpClientConfiguration.Default)]
internal sealed partial class CalculateClient
{
private readonly IHttpRequestMessageBuilderFactory httpRequestMessageBuilderFactory;
+ private readonly IHttpClientFactory httpClientFactory;
private readonly ILogger logger;
- private readonly HttpClient httpClient;
- ///
- /// 异步计算结果
- ///
- /// 用户
- /// 差异
- /// 取消令牌
- /// 消耗结果
- [ApiInformation(Cookie = CookieType.Cookie)]
public async ValueTask> ComputeAsync(Model.Entity.User user, AvatarPromotionDelta delta, CancellationToken token = default)
{
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
@@ -40,18 +29,12 @@ internal sealed partial class CalculateClient
.PostJson(delta);
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(CalculateClient)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
}
- ///
- /// 异步获取角色列表
- ///
- /// 用户与角色
- /// 取消令牌
- /// 角色列表
public async ValueTask> GetAvatarsAsync(UserAndUid userAndUid, CancellationToken token = default)
{
int currentPage = 1;
@@ -71,7 +54,7 @@ internal sealed partial class CalculateClient
.PostJson(filter);
resp = await builder
- .TryCatchSendAsync>>(httpClient, logger, token)
+ .TryCatchSendAsync>>(httpClientFactory.CreateClient(nameof(CalculateClient)), logger, token)
.ConfigureAwait(false);
if (resp is not null && resp.IsOk())
@@ -91,13 +74,6 @@ internal sealed partial class CalculateClient
return avatars;
}
- ///
- /// 异步获取角色详情
- ///
- /// 用户与角色
- /// 角色
- /// 取消令牌
- /// 角色详情
public async ValueTask> GetAvatarDetailAsync(UserAndUid userAndUid, Avatar avatar, CancellationToken token = default)
{
string url = userAndUid.User.IsOversea
@@ -111,19 +87,12 @@ internal sealed partial class CalculateClient
.Get();
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(CalculateClient)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
}
- ///
- /// 异步获取摹本的家具列表
- ///
- /// 用户
- /// 摹本码
- /// 取消令牌
- /// 家具列表
public async ValueTask> FurnitureBlueprintAsync(Model.Entity.User user, string shareCode, CancellationToken token)
{
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
@@ -133,19 +102,12 @@ internal sealed partial class CalculateClient
.Get();
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(CalculateClient)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
}
- ///
- /// 家具数量计算
- ///
- /// 用户
- /// 物品
- /// 取消令牌
- /// 消耗
public async ValueTask>> FurnitureComputeAsync(Model.Entity.User user, List- items, CancellationToken token)
{
ListWrapper data = new() { List = items.Select(i => new IdCount { Id = i.Id, Count = i.Num }).ToList() };
@@ -157,7 +119,7 @@ internal sealed partial class CalculateClient
.PostJson(data);
Response>? resp = await builder
- .TryCatchSendAsync>>(httpClient, logger, token)
+ .TryCatchSendAsync>>(httpClientFactory.CreateClient(nameof(CalculateClient)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/GameRecord/GameRecordClient.cs b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/GameRecord/GameRecordClient.cs
index 34f78c9b..83aa0908 100644
--- a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/GameRecord/GameRecordClient.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/GameRecord/GameRecordClient.cs
@@ -14,9 +14,6 @@ using System.Net.Http;
namespace Snap.Hutao.Web.Hoyolab.Takumi.GameRecord;
-///
-/// 游戏记录提供器
-///
[HighQuality]
[ConstructorGenerated(ResolveHttpClient = true)]
[HttpClient(HttpClientConfiguration.XRpc)]
@@ -24,11 +21,10 @@ namespace Snap.Hutao.Web.Hoyolab.Takumi.GameRecord;
internal sealed partial class GameRecordClient : IGameRecordClient
{
private readonly IHttpRequestMessageBuilderFactory httpRequestMessageBuilderFactory;
+ private readonly IHttpClientFactory httpClientFactory;
private readonly IServiceProvider serviceProvider;
private readonly ILogger logger;
- private readonly HttpClient httpClient;
- [ApiInformation(Cookie = CookieType.Cookie, Salt = SaltType.X4)]
public async ValueTask> GetDailyNoteAsync(UserAndUid userAndUid, CancellationToken token = default)
{
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
@@ -40,7 +36,7 @@ internal sealed partial class GameRecordClient : IGameRecordClient
await builder.SignDataAsync(DataSignAlgorithmVersion.Gen2, SaltType.X4, false).ConfigureAwait(false);
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(GameRecordClient)), logger, token)
.ConfigureAwait(false);
// We have a verification procedure to handle
@@ -64,7 +60,7 @@ internal sealed partial class GameRecordClient : IGameRecordClient
await verifiedbuilder.SignDataAsync(DataSignAlgorithmVersion.Gen2, SaltType.X4, false).ConfigureAwait(false);
resp = await verifiedbuilder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(GameRecordClient)), logger, token)
.ConfigureAwait(false);
}
}
@@ -72,7 +68,6 @@ internal sealed partial class GameRecordClient : IGameRecordClient
return Response.Response.DefaultIfNull(resp);
}
- [ApiInformation(Cookie = CookieType.LToken, Salt = SaltType.X4)]
public async ValueTask> GetPlayerInfoAsync(UserAndUid userAndUid, CancellationToken token = default)
{
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
@@ -84,7 +79,7 @@ internal sealed partial class GameRecordClient : IGameRecordClient
await builder.SignDataAsync(DataSignAlgorithmVersion.Gen2, SaltType.X4, false).ConfigureAwait(false);
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(GameRecordClient)), logger, token)
.ConfigureAwait(false);
// We have a verification procedure to handle
@@ -108,7 +103,7 @@ internal sealed partial class GameRecordClient : IGameRecordClient
await verifiedbuilder.SignDataAsync(DataSignAlgorithmVersion.Gen2, SaltType.X4, false).ConfigureAwait(false);
resp = await verifiedbuilder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(GameRecordClient)), logger, token)
.ConfigureAwait(false);
}
}
@@ -116,14 +111,6 @@ internal sealed partial class GameRecordClient : IGameRecordClient
return Response.Response.DefaultIfNull(resp);
}
- ///
- /// 获取玩家深渊信息
- ///
- /// 用户
- /// 1:当期,2:上期
- /// 取消令牌
- /// 深渊信息
- [ApiInformation(Cookie = CookieType.Cookie, Salt = SaltType.X4)]
public async ValueTask> GetSpiralAbyssAsync(UserAndUid userAndUid, SpiralAbyssSchedule schedule, CancellationToken token = default)
{
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
@@ -135,7 +122,7 @@ internal sealed partial class GameRecordClient : IGameRecordClient
await builder.SignDataAsync(DataSignAlgorithmVersion.Gen2, SaltType.X4, false).ConfigureAwait(false);
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(GameRecordClient)), logger, token)
.ConfigureAwait(false);
// We have a verification procedure to handle
@@ -159,7 +146,7 @@ internal sealed partial class GameRecordClient : IGameRecordClient
await verifiedbuilder.SignDataAsync(DataSignAlgorithmVersion.Gen2, SaltType.X4, false).ConfigureAwait(false);
resp = await verifiedbuilder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(GameRecordClient)), logger, token)
.ConfigureAwait(false);
}
}
@@ -167,13 +154,6 @@ internal sealed partial class GameRecordClient : IGameRecordClient
return Response.Response.DefaultIfNull(resp);
}
- ///
- /// 异步获取角色基本信息
- ///
- /// 用户与角色
- /// 取消令牌
- /// 角色基本信息
- [ApiInformation(Cookie = CookieType.LToken, Salt = SaltType.X4)]
public async ValueTask> GetRoleBasicInfoAsync(UserAndUid userAndUid, CancellationToken token = default)
{
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
@@ -185,20 +165,12 @@ internal sealed partial class GameRecordClient : IGameRecordClient
await builder.SignDataAsync(DataSignAlgorithmVersion.Gen2, SaltType.X4, false).ConfigureAwait(false);
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(GameRecordClient)), logger, token)
.ConfigureAwait(false);
return Response.Response.DefaultIfNull(resp);
}
- ///
- /// 获取玩家角色详细信息
- ///
- /// 用户与角色
- /// 玩家的基础信息
- /// 取消令牌
- /// 角色列表
- [ApiInformation(Cookie = CookieType.LToken, Salt = SaltType.X4)]
public async ValueTask> GetCharactersAsync(UserAndUid userAndUid, PlayerInfo playerInfo, CancellationToken token = default)
{
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
@@ -210,7 +182,7 @@ internal sealed partial class GameRecordClient : IGameRecordClient
await builder.SignDataAsync(DataSignAlgorithmVersion.Gen2, SaltType.X4, false).ConfigureAwait(false);
Response? resp = await builder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(GameRecordClient)), logger, token)
.ConfigureAwait(false);
// We have a verification procedure to handle
@@ -234,7 +206,7 @@ internal sealed partial class GameRecordClient : IGameRecordClient
await verifiedBuilder.SignDataAsync(DataSignAlgorithmVersion.Gen2, SaltType.X4, false).ConfigureAwait(false);
resp = await verifiedBuilder
- .TryCatchSendAsync>(httpClient, logger, token)
+ .TryCatchSendAsync>(httpClientFactory.CreateClient(nameof(GameRecordClient)), logger, token)
.ConfigureAwait(false);
}
}