提交代码
This commit is contained in:
parent
e4f13fab6c
commit
e5300bc59c
|
|
@ -4,6 +4,8 @@
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
|
<DockerfileContext>..\..</DockerfileContext>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
35
src/CloudGaming/Api/CloudGaming.ExtApi/Dockerfile
Normal file
35
src/CloudGaming/Api/CloudGaming.ExtApi/Dockerfile
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
# 请参阅 https://aka.ms/customizecontainer 以了解如何自定义调试容器,以及 Visual Studio 如何使用此 Dockerfile 生成映像以更快地进行调试。
|
||||||
|
|
||||||
|
# 此阶段用于在快速模式(默认为调试配置)下从 VS 运行时
|
||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
||||||
|
USER $APP_UID
|
||||||
|
WORKDIR /app
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
|
||||||
|
# 此阶段用于生成服务项目
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||||
|
ARG BUILD_CONFIGURATION=Release
|
||||||
|
WORKDIR /src
|
||||||
|
COPY ["Api/CloudGaming.ExtApi/CloudGaming.ExtApi.csproj", "Api/CloudGaming.ExtApi/"]
|
||||||
|
COPY ["Code/CloudGaming.Code/CloudGaming.Code.csproj", "Code/CloudGaming.Code/"]
|
||||||
|
COPY ["Model/CloudGaming.AppConfigModel/CloudGaming.AppConfigModel.csproj", "Model/CloudGaming.AppConfigModel/"]
|
||||||
|
COPY ["Model/CloudGaming.DtoModel/CloudGaming.DtoModel.csproj", "Model/CloudGaming.DtoModel/"]
|
||||||
|
COPY ["Model/CloudGaming.GameModel/CloudGaming.GameModel.csproj", "Model/CloudGaming.GameModel/"]
|
||||||
|
COPY ["Utile/HuanMeng.DotNetCore/HuanMeng.DotNetCore.csproj", "Utile/HuanMeng.DotNetCore/"]
|
||||||
|
COPY ["Model/CloudGaming.Model/CloudGaming.Model.csproj", "Model/CloudGaming.Model/"]
|
||||||
|
RUN dotnet restore "./Api/CloudGaming.ExtApi/CloudGaming.ExtApi.csproj"
|
||||||
|
COPY . .
|
||||||
|
WORKDIR "/src/Api/CloudGaming.ExtApi"
|
||||||
|
RUN dotnet build "./CloudGaming.ExtApi.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||||
|
|
||||||
|
# 此阶段用于发布要复制到最终阶段的服务项目
|
||||||
|
FROM build AS publish
|
||||||
|
ARG BUILD_CONFIGURATION=Release
|
||||||
|
RUN dotnet publish "./CloudGaming.ExtApi.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||||
|
|
||||||
|
# 此阶段在生产中使用,或在常规模式下从 VS 运行时使用(在不使用调试配置时为默认值)
|
||||||
|
FROM base AS final
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=publish /app/publish .
|
||||||
|
ENTRYPOINT ["dotnet", "CloudGaming.ExtApi.dll"]
|
||||||
|
|
@ -63,6 +63,8 @@ public class PlayGameProcessor(IServiceProvider serviceProvider) : ThreadProcess
|
||||||
var userNotActionEndGame = DateTime.Now.AddSeconds(-appConfig.GameConfig.UserNotActionEndGame);
|
var userNotActionEndGame = DateTime.Now.AddSeconds(-appConfig.GameConfig.UserNotActionEndGame);
|
||||||
|
|
||||||
using var scope = serviceProvider.CreateScope();
|
using var scope = serviceProvider.CreateScope();
|
||||||
|
var app = scope.ServiceProvider.GetRequiredService<AppConfig>();
|
||||||
|
appConfig.ToAppConfig(app);
|
||||||
var dao = scope.ServiceProvider.GetDAO(appConfig);
|
var dao = scope.ServiceProvider.GetDAO(appConfig);
|
||||||
var redis = appConfig.GetRedisDataBase();
|
var redis = appConfig.GetRedisDataBase();
|
||||||
var redisServer = appConfig.GetRedisServer();
|
var redisServer = appConfig.GetRedisServer();
|
||||||
|
|
@ -106,7 +108,8 @@ public class PlayGameProcessor(IServiceProvider serviceProvider) : ThreadProcess
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private async Task EndGameAsync(PlayGameUserInfo user, AppConfig appConfig, DAO dao, IDatabase redis)
|
private async Task EndGameAsync(PlayGameUserInfo user, AppConfig appConfig, DAO dao, IDatabase redis)
|
||||||
{
|
{
|
||||||
using HttpClient httpClient = new HttpClient(new JYApiAppConfigHandler(appConfig, user.Ip));
|
HttpClient httpClient = new HttpClient(new JYApiAppConfigHandler(appConfig, user.Ip));
|
||||||
|
httpClient.BaseAddress = new Uri(appConfig.GameConfig.BsUrl);
|
||||||
var jyApi = RestService.For<IJYApi>(httpClient);
|
var jyApi = RestService.For<IJYApi>(httpClient);
|
||||||
|
|
||||||
var playGameCommonSetting = new PlayGameCommonSetting
|
var playGameCommonSetting = new PlayGameCommonSetting
|
||||||
|
|
|
||||||
|
|
@ -7,50 +7,30 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace CloudGaming.Code.JY
|
namespace CloudGaming.Code.JY;
|
||||||
|
|
||||||
|
public class JYApiAppConfigHandler : JYApiHandler
|
||||||
{
|
{
|
||||||
public class JYApiAppConfigHandler : JYApiHandler
|
protected AppConfig AppConfig { get; set; }
|
||||||
|
protected string Ip { get; set; }
|
||||||
|
public JYApiAppConfigHandler(AppConfig appConfig, string ip) : base(null)
|
||||||
{
|
{
|
||||||
protected AppConfig AppConfig { get; set; }
|
AppConfig = appConfig;
|
||||||
protected string Ip { get; set; }
|
Ip = ip;
|
||||||
public JYApiAppConfigHandler(AppConfig appConfig, string ip) : base(null)
|
InnerHandler = new HttpClientHandler();
|
||||||
{
|
}
|
||||||
AppConfig = appConfig;
|
|
||||||
Ip = ip;
|
|
||||||
}
|
|
||||||
|
|
||||||
//protected new async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
|
||||||
//{
|
protected override async Task SetRequest(HttpRequestMessage request)
|
||||||
// try
|
{
|
||||||
// {
|
|
||||||
// await SetRequest(request);
|
UpdateRequestUri(request, AppConfig.GameConfig.BsUrl);
|
||||||
// var sw = Stopwatch.StartNew();
|
|
||||||
// var response = await base.SendAsync(request, cancellationToken);
|
if (request.Content is FormUrlEncodedContent)
|
||||||
// sw.Stop();
|
|
||||||
// if (response.IsSuccessStatusCode)
|
|
||||||
// {
|
|
||||||
// await AttachDebugInfoAsync(request, response, sw.Elapsed.TotalMilliseconds.ToString());
|
|
||||||
// }
|
|
||||||
// return response;
|
|
||||||
// }
|
|
||||||
// catch (Exception ex)
|
|
||||||
// {
|
|
||||||
// // 可根据实际需要扩展异常处理逻辑
|
|
||||||
// throw new HttpRequestException("发送请求时发生错误。", ex);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
protected override async Task SetRequest(HttpRequestMessage request)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
await UpdateRequestContentAsync(request, AppConfig, Ip);
|
||||||
UpdateRequestUri(request, AppConfig.GameConfig.BsUrl);
|
|
||||||
|
|
||||||
if (request.Content is FormUrlEncodedContent)
|
|
||||||
{
|
|
||||||
|
|
||||||
await UpdateRequestContentAsync(request, AppConfig, Ip);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user