From e20cb9d5578b1a9f41975a8fda3ba9ee4778cd8f Mon Sep 17 00:00:00 2001 From: zpc Date: Thu, 28 Nov 2024 14:08:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8E=B7=E5=8F=96token?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/PlayGameController.cs | 2 +- .../CloudGaming.ExtApi.csproj | 26 ++++ .../CloudGaming.ExtApi.http | 6 + .../Controllers/WeatherForecastController.cs | 33 +++++ .../Api/CloudGaming.ExtApi/Program.cs | 139 ++++++++++++++++++ .../Properties/launchSettings.json | 31 ++++ .../Api/CloudGaming.ExtApi/WeatherForecast.cs | 13 ++ .../appsettings.Development.json | 26 ++++ .../Api/CloudGaming.ExtApi/appsettings.json | 72 +++++++++ .../appsettings.Development.json | 2 +- src/CloudGaming/CloudGaming.sln | 7 + .../Code/CloudGaming.Code/Game/PlayGameBLL.cs | 27 +++- .../CloudGaming.Code/Game/PlayGameExtend.cs | 14 +- .../CloudGaming.Code/Game/PlayGameService.cs | 21 +++ .../PlayGame/GetTokenRequest.cs | 19 +++ .../PlayGame/PlayGameUserOperation.cs | 2 +- 16 files changed, 434 insertions(+), 6 deletions(-) create mode 100644 src/CloudGaming/Api/CloudGaming.ExtApi/CloudGaming.ExtApi.csproj create mode 100644 src/CloudGaming/Api/CloudGaming.ExtApi/CloudGaming.ExtApi.http create mode 100644 src/CloudGaming/Api/CloudGaming.ExtApi/Controllers/WeatherForecastController.cs create mode 100644 src/CloudGaming/Api/CloudGaming.ExtApi/Program.cs create mode 100644 src/CloudGaming/Api/CloudGaming.ExtApi/Properties/launchSettings.json create mode 100644 src/CloudGaming/Api/CloudGaming.ExtApi/WeatherForecast.cs create mode 100644 src/CloudGaming/Api/CloudGaming.ExtApi/appsettings.Development.json create mode 100644 src/CloudGaming/Api/CloudGaming.ExtApi/appsettings.json create mode 100644 src/CloudGaming/Code/CloudGaming.Code/Game/PlayGameService.cs create mode 100644 src/CloudGaming/Model/CloudGaming.DtoModel/PlayGame/GetTokenRequest.cs diff --git a/src/CloudGaming/Api/CloudGaming.Api/Controllers/PlayGameController.cs b/src/CloudGaming/Api/CloudGaming.Api/Controllers/PlayGameController.cs index b59639f..eb4194b 100644 --- a/src/CloudGaming/Api/CloudGaming.Api/Controllers/PlayGameController.cs +++ b/src/CloudGaming/Api/CloudGaming.Api/Controllers/PlayGameController.cs @@ -37,7 +37,7 @@ public class PlayGameController : CloudGamingControllerBase /// [HttpPost] [Authorize] - public async Task> GetTokenAsync([FromBody] RequestBaseModel requestBaseModel) + public async Task> GetTokenAsync([FromBody] GetTokenRequest requestBaseModel) { PlayGameBLL playGameBLL = new PlayGameBLL(ServiceProvider, JYApi); diff --git a/src/CloudGaming/Api/CloudGaming.ExtApi/CloudGaming.ExtApi.csproj b/src/CloudGaming/Api/CloudGaming.ExtApi/CloudGaming.ExtApi.csproj new file mode 100644 index 0000000..062516c --- /dev/null +++ b/src/CloudGaming/Api/CloudGaming.ExtApi/CloudGaming.ExtApi.csproj @@ -0,0 +1,26 @@ + + + + net8.0 + enable + enable + + + + + + + + + + + + + + + + + + + + diff --git a/src/CloudGaming/Api/CloudGaming.ExtApi/CloudGaming.ExtApi.http b/src/CloudGaming/Api/CloudGaming.ExtApi/CloudGaming.ExtApi.http new file mode 100644 index 0000000..d4f19e8 --- /dev/null +++ b/src/CloudGaming/Api/CloudGaming.ExtApi/CloudGaming.ExtApi.http @@ -0,0 +1,6 @@ +@CloudGaming.ExtApi_HostAddress = http://localhost:5183 + +GET {{CloudGaming.ExtApi_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/src/CloudGaming/Api/CloudGaming.ExtApi/Controllers/WeatherForecastController.cs b/src/CloudGaming/Api/CloudGaming.ExtApi/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..9a21e26 --- /dev/null +++ b/src/CloudGaming/Api/CloudGaming.ExtApi/Controllers/WeatherForecastController.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Mvc; + +namespace CloudGaming.ExtApi.Controllers +{ + [ApiController] + [Route("[controller]")] + public class WeatherForecastController : ControllerBase + { + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + public WeatherForecastController(ILogger logger) + { + _logger = logger; + } + + [HttpGet(Name = "GetWeatherForecast")] + public IEnumerable Get() + { + return Enumerable.Range(1, 5).Select(index => new WeatherForecast + { + Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), + TemperatureC = Random.Shared.Next(-20, 55), + Summary = Summaries[Random.Shared.Next(Summaries.Length)] + }) + .ToArray(); + } + } +} diff --git a/src/CloudGaming/Api/CloudGaming.ExtApi/Program.cs b/src/CloudGaming/Api/CloudGaming.ExtApi/Program.cs new file mode 100644 index 0000000..7214154 --- /dev/null +++ b/src/CloudGaming/Api/CloudGaming.ExtApi/Program.cs @@ -0,0 +1,139 @@ +using CloudGaming.Code.AppExtend; +using CloudGaming.Code.DataAccess.MultiTenantUtil; +using CloudGaming.Code.Filter; + +using HuanMeng.DotNetCore.MiddlewareExtend; +using HuanMeng.DotNetCore.SwaggerUtile; + +using Microsoft.AspNetCore.Authentication.JwtBearer; + +using Microsoft.OpenApi.Models; + +using Newtonsoft.Json.Serialization; + +using Serilog; + +using System.Diagnostics; +using System.Reflection; + +var builder = WebApplication.CreateBuilder(args); + +#region 日志 +// Add services to the container. +builder.Host.UseSerilog((context, services, configuration) => configuration + .ReadFrom.Configuration(context.Configuration) + .ReadFrom.Services(services) + .Enrich.FromLogContext()); + +builder.Services.AddSingleton(typeof(ILogger), serviceProvider => +{ + var loggerFactory = serviceProvider.GetRequiredService(); + return loggerFactory.CreateLogger(); +}); +// +builder.Services.AddSingleton(typeof(ILogger), serviceProvider => +{ + var loggerFactory = serviceProvider.GetRequiredService(); + return loggerFactory.CreateLogger(); +}); +#endregion + +builder.Services.AddHttpContextAccessor(); //添加httpContext注入访问 +#region 返回数据解析 +//builder.Services.AddControllers(); +builder.Services.AddControllers(options => +{ +}) + .AddNewtonsoftJson(options => + { + // 配置 Newtonsoft.Json 选项 + options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; // 忽略循环引用 + options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();// 首字母小写(驼峰样式) + //options.SerializerSettings.ContractResolver = new LanguageContractResolver(builder.Services); + options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";// 时间格式化 + options.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.None; + }); +//CustomResultFilter +//builder.Services.AddSingleton(); + +#endregion + +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(c => +{ + + + string description = ""; + var filePath = Path.GetFullPath(".versionDescribe"); + if (File.Exists(filePath)) + { + description = File.ReadAllText(filePath); + } + c.SwaggerDoc("v1", new OpenApiInfo { Title = "蒸汽云游戏扩展付", Version = "0.0.1", Description = description }); + foreach (var assemblies in AppDomain.CurrentDomain.GetAssemblies()) + { + // 添加 XML 注释文件路径 + var xmlFile = $"{assemblies.GetName().Name}.xml"; + var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); + if (File.Exists(xmlPath)) + { + c.IncludeXmlComments(xmlPath); + } + } + c.ParameterFilter(); + c.RequestBodyFilter(); +}); +builder.AddAppConfigClient(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +//if (app.Environment.IsDevelopment()) +//{ +app.UseSwagger(); +app.UseSwaggerUI(c => +{ + + c.EnableDeepLinking(); + c.DefaultModelsExpandDepth(3); + c.DefaultModelExpandDepth(3); + c.EnableFilter("true"); + //c.RoutePrefix = string.Empty; + c.SwaggerEndpoint("/swagger/v1/swagger.json", "蒸汽云游戏扩展 API V1"); + // 使用自定义CSS + c.InjectStylesheet("/custom.css"); +}); +//} + +app.UseAuthorization(); +//数据库中间件 +app.UseMultiTenant(); +app.MapControllers(); +app.UseMiddlewareAll(); +#region 默认请求 +app.MapGet("/", () => "请求成功").WithName("默认请求"); + +var startDateTime = DateTime.Now; +var InformationalVersion = Assembly.GetEntryAssembly().GetCustomAttribute().InformationalVersion; +Console.WriteLine($"version:{InformationalVersion}"); +app.MapGet("/system", () => +{ + + using Process currentProcess = Process.GetCurrentProcess(); + // CPU使用率 (一般是一个0-100之间的值,但实际是时间占比,需要转换) + double cpuUsage = currentProcess.TotalProcessorTime.TotalMilliseconds / Environment.TickCount * 100; + // 已用内存 (字节) + long memoryUsage = currentProcess.WorkingSet64; + return new + { + msg = $"系统信息:启动时间:{startDateTime.ToString("yyyy-MM-dd HH:mm:ss")},已安全运行时间:{DateTime.Now.Subtract(startDateTime).TotalMinutes.ToString("0.##")}分钟", + + startDateTime, + MemoryUsage = $"{memoryUsage / (1024.0 * 1024.0):F2}MB", + CPUUsage = $"{cpuUsage:F2}%" + + }; +}).WithName("获取系统数据"); +#endregion +app.Run(); diff --git a/src/CloudGaming/Api/CloudGaming.ExtApi/Properties/launchSettings.json b/src/CloudGaming/Api/CloudGaming.ExtApi/Properties/launchSettings.json new file mode 100644 index 0000000..b4cf1af --- /dev/null +++ b/src/CloudGaming/Api/CloudGaming.ExtApi/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:4142", + "sslPort": 0 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5183", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/CloudGaming/Api/CloudGaming.ExtApi/WeatherForecast.cs b/src/CloudGaming/Api/CloudGaming.ExtApi/WeatherForecast.cs new file mode 100644 index 0000000..ec47525 --- /dev/null +++ b/src/CloudGaming/Api/CloudGaming.ExtApi/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace CloudGaming.ExtApi +{ + public class WeatherForecast + { + public DateOnly Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string? Summary { get; set; } + } +} diff --git a/src/CloudGaming/Api/CloudGaming.ExtApi/appsettings.Development.json b/src/CloudGaming/Api/CloudGaming.ExtApi/appsettings.Development.json new file mode 100644 index 0000000..3e455c4 --- /dev/null +++ b/src/CloudGaming/Api/CloudGaming.ExtApi/appsettings.Development.json @@ -0,0 +1,26 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AgileConfig": { + "appId": "CloudGaming", + "secret": "95BB717C61D1ECB0E9FB82C932CC77FF", + "nodes": "http://124.220.55.158:94", //多个节点使用逗号分隔 + "url": "http://124.220.55.158:94", + "env": "DEV", + "name": "payClient", + "UserName": "admin", + "Password": "dbt@com@1234" + }, + //服务器配置 + "Kestrel": { + "Endpoints": { + "Http": { + "Url": "http://*:804" + } + } + } +} diff --git a/src/CloudGaming/Api/CloudGaming.ExtApi/appsettings.json b/src/CloudGaming/Api/CloudGaming.ExtApi/appsettings.json new file mode 100644 index 0000000..7e6df50 --- /dev/null +++ b/src/CloudGaming/Api/CloudGaming.ExtApi/appsettings.json @@ -0,0 +1,72 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*", + "Serilog": { + "Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ], + "MinimumLevel": { + "Default": "Information", + "Override": { + "Microsoft": "Warning", + "System": "Warning" + } + }, + "WriteTo": [ + { "Name": "Console" }, + { + "Name": "File", + "Args": { + "path": "../output/extlogs/info/log-.txt", + "rollingInterval": "Day", + "restrictedToMinimumLevel": "Information", //写入日志的级别 + "shared": true + //"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "../output/extlogs/error/log-.txt", + "rollingInterval": "Day", //日志文件按天滚动生成。 + "restrictedToMinimumLevel": "Error", //写入日志的级别 //包括 Verbose、Debug、Information、Warning、Error 和 Fatal + "shared": true //不占用文件 + // "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}" + } + }, + { + "Name": "File", + "Args": { + "path": "../output/extlogs/debug/log-.txt", + "rollingInterval": "Day", //日志文件按天滚动生成。 + "restrictedToMinimumLevel": "Debug", //写入日志的级别 //包括 Verbose、Debug、Information、Warning、Error 和 Fatal + "shared": true //不占用文件 + // "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}" + } + } + ], + "Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ] + }, + "AgileConfig": { + "appId": "CloudGaming", + "secret": "95BB717C61D1ECB0E9FB82C932CC77FF", + "nodes": "http://124.220.55.158:94", //多个节点使用逗号分隔 + "url": "http://124.220.55.158:94", + "env": "TEST", + "name": "payClient", + "UserName": "admin", + "Password": "dbt@com@1234" + }, + //服务器配置 + "Kestrel": { + "Endpoints": { + "Http": { + "Url": "http://*:80" + } + } + } + +} diff --git a/src/CloudGaming/Api/CloudGaming.PayApi/appsettings.Development.json b/src/CloudGaming/Api/CloudGaming.PayApi/appsettings.Development.json index dc69270..9335132 100644 --- a/src/CloudGaming/Api/CloudGaming.PayApi/appsettings.Development.json +++ b/src/CloudGaming/Api/CloudGaming.PayApi/appsettings.Development.json @@ -19,7 +19,7 @@ "Kestrel": { "Endpoints": { "Http": { - "Url": "http://*:802" + "Url": "http://*:803" } } } diff --git a/src/CloudGaming/CloudGaming.sln b/src/CloudGaming/CloudGaming.sln index 8bd7ca8..0f7c52c 100644 --- a/src/CloudGaming/CloudGaming.sln +++ b/src/CloudGaming/CloudGaming.sln @@ -40,6 +40,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudGaming.PayApi", "Api\C EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudGaming.AppConfigModel", "Model\CloudGaming.AppConfigModel\CloudGaming.AppConfigModel.csproj", "{58FD9A2F-E1FC-494C-9484-D5BCA8511EBE}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudGaming.ExtApi", "Api\CloudGaming.ExtApi\CloudGaming.ExtApi.csproj", "{64997DCB-487F-4617-A43C-10AD78B91B29}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -86,6 +88,10 @@ Global {58FD9A2F-E1FC-494C-9484-D5BCA8511EBE}.Debug|Any CPU.Build.0 = Debug|Any CPU {58FD9A2F-E1FC-494C-9484-D5BCA8511EBE}.Release|Any CPU.ActiveCfg = Release|Any CPU {58FD9A2F-E1FC-494C-9484-D5BCA8511EBE}.Release|Any CPU.Build.0 = Release|Any CPU + {64997DCB-487F-4617-A43C-10AD78B91B29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {64997DCB-487F-4617-A43C-10AD78B91B29}.Debug|Any CPU.Build.0 = Debug|Any CPU + {64997DCB-487F-4617-A43C-10AD78B91B29}.Release|Any CPU.ActiveCfg = Release|Any CPU + {64997DCB-487F-4617-A43C-10AD78B91B29}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -101,6 +107,7 @@ Global {830841B9-E013-4FD5-8D31-D85545870C1C} = {9F7EF36C-17BB-4F93-927E-F462FE3C9337} {452D87B5-A7E0-4EBD-9CF2-1AFF5941065B} = {51CB40D2-99F5-43E8-95B4-3A75C91736A6} {58FD9A2F-E1FC-494C-9484-D5BCA8511EBE} = {A3F00FB0-49D6-48B1-99D9-4619634DF8D9} + {64997DCB-487F-4617-A43C-10AD78B91B29} = {51CB40D2-99F5-43E8-95B4-3A75C91736A6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1D299D92-FA27-47A0-8D78-43D1FAFE7628} diff --git a/src/CloudGaming/Code/CloudGaming.Code/Game/PlayGameBLL.cs b/src/CloudGaming/Code/CloudGaming.Code/Game/PlayGameBLL.cs index 1b9678e..51f1314 100644 --- a/src/CloudGaming/Code/CloudGaming.Code/Game/PlayGameBLL.cs +++ b/src/CloudGaming/Code/CloudGaming.Code/Game/PlayGameBLL.cs @@ -26,7 +26,7 @@ public class PlayGameBLL : CloudGamingBase /// /// /// - public async Task> GetTokenAsync(RequestBaseModel requestBaseModel) + public async Task> GetTokenAsync(GetTokenRequest requestBaseModel) { if (_UserId == 0) { @@ -38,10 +38,29 @@ public class PlayGameBLL : CloudGamingBase } //requestBaseModel.Sn = Guid.NewGuid().ToString(); JYRequestParameter requestParameter = new JYRequestParameter(requestBaseModel.Sn, _UserId); + // 检查游戏是否存在 + var gameCache = Cache.GameEntityCache; + var gameInfo = gameCache[requestBaseModel.GameId]; + if (gameInfo == null) + { + throw MessageBox.ErrorShow("游戏不存在"); + } + + // 检查用户钻石是否足够 + if (UserInfo.Diamond <= 0) + { + throw MessageBox.Show(ResponseCode.NotMoney, "钻石不足"); + } + + var data = await JYApi.GetToken(requestParameter); + //Console.WriteLine(jyResponseData.TotalMilliseconds); if (data.IsSuccess) { + // 获取用户和游戏信息 + var userInfo = UserInfo; + PlayGameUserInfo gameInfoCache = await PlayGameExtend.GetPlayGameUserInfoCacheAsync(this, userInfo, gameInfo); return new BaseResponse(ResponseCode.Success, "", data?.Data ?? new GetTokenModel()); } throw data.ToMessageBox(); @@ -101,8 +120,12 @@ public class PlayGameBLL : CloudGamingBase HangUpTimer = 300, // 挂机时间 5 分钟 ModelName = playGameRequest.ModelName, StartResolution = "1080P", - Cpu = playGameRequest.Cpu, + }; + if (!string.IsNullOrEmpty(playGameRequest.Cpu)) + { + playGameSettings.Cpu = playGameRequest.Cpu; + } //设置开始游戏数据 gameInfoCache.InitStartPlayGame(playGameSettings); // 调用鲸云游戏启动接口 diff --git a/src/CloudGaming/Code/CloudGaming.Code/Game/PlayGameExtend.cs b/src/CloudGaming/Code/CloudGaming.Code/Game/PlayGameExtend.cs index 9a45d93..d2d2d9b 100644 --- a/src/CloudGaming/Code/CloudGaming.Code/Game/PlayGameExtend.cs +++ b/src/CloudGaming/Code/CloudGaming.Code/Game/PlayGameExtend.cs @@ -22,7 +22,7 @@ namespace CloudGaming.Code.Game /// /// /// - public static async Task GetPlayGameUserInfoCacheAsync(CloudGamingBase cloudGamingBase, UserInfo userInfo, GameInfo gameInfo) + public static async Task GetPlayGameUserInfoCacheAsync(CloudGamingBase cloudGamingBase, UserInfo userInfo, GameInfo gameInfo, IJYApiRespnse? jYApiRespnse = null) { var redisGameKey = GetPlayGameKey(gameInfo.GameId, userInfo.UserId); var gameInfoCache = await cloudGamingBase.RedisCache.StringGetAsync(redisGameKey); @@ -40,6 +40,18 @@ namespace CloudGaming.Code.Game SessionId = Guid.NewGuid().ToString("N"), }; } + if (jYApiRespnse != null) + { + if (gameInfoCache.GameUserOperation == null) + { + gameInfoCache.GameUserOperation = new List(); + } + gameInfoCache.GameUserOperation.Add(new PlayGameUserOperation(jYApiRespnse) + { + Content = "获取token", + OperationDateTime = DateTime.Now, + }); + } return gameInfoCache; } diff --git a/src/CloudGaming/Code/CloudGaming.Code/Game/PlayGameService.cs b/src/CloudGaming/Code/CloudGaming.Code/Game/PlayGameService.cs new file mode 100644 index 0000000..e83bae9 --- /dev/null +++ b/src/CloudGaming/Code/CloudGaming.Code/Game/PlayGameService.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CloudGaming.Code.Game; + +public class PlayGameService(IServiceProvider serviceProvider) : IHostedService +{ + public Task StartAsync(CancellationToken cancellationToken) + { + //AppConfigurationExtend.AppConfigs.Select(it => it.Value).Where(it => it.DomainName != "default").ToList(); + throw new NotImplementedException(); + } + + public Task StopAsync(CancellationToken cancellationToken) + { + throw new NotImplementedException(); + } +} diff --git a/src/CloudGaming/Model/CloudGaming.DtoModel/PlayGame/GetTokenRequest.cs b/src/CloudGaming/Model/CloudGaming.DtoModel/PlayGame/GetTokenRequest.cs new file mode 100644 index 0000000..2c1011b --- /dev/null +++ b/src/CloudGaming/Model/CloudGaming.DtoModel/PlayGame/GetTokenRequest.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CloudGaming.DtoModel.PlayGame +{ + /// + /// 获取token + /// + public class GetTokenRequest : RequestBaseModel + { + /// + /// 游戏Id + /// + public string GameId { get; set; } + } +} diff --git a/src/CloudGaming/Model/CloudGaming.DtoModel/PlayGame/PlayGameUserOperation.cs b/src/CloudGaming/Model/CloudGaming.DtoModel/PlayGame/PlayGameUserOperation.cs index 9ca1aa1..29ee602 100644 --- a/src/CloudGaming/Model/CloudGaming.DtoModel/PlayGame/PlayGameUserOperation.cs +++ b/src/CloudGaming/Model/CloudGaming.DtoModel/PlayGame/PlayGameUserOperation.cs @@ -18,7 +18,7 @@ namespace CloudGaming.DtoModel.PlayGame } public PlayGameUserOperation(IJYApiRespnse? jYApiRespnse) { - RequestContent = jYApiRespnse?.ResponseStr; + RequestContent = jYApiRespnse?.RequestStr; ResponseContent = jYApiRespnse?.ResponseContent; TotalMilliseconds = jYApiRespnse?.TotalMilliseconds; }