添加游戏功能
This commit is contained in:
parent
93c27b5c55
commit
6c5a7b8019
|
|
@ -122,7 +122,7 @@ namespace CloudGaming.Api.Controllers
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public async Task<BaseResponse<bool>> GameCollect([FromBody] GameCollectRequest collectRequest)
|
public async Task<BaseResponse<bool>> GameCollect([FromBody] GameRequest collectRequest)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(collectRequest.GameId))
|
if (string.IsNullOrEmpty(collectRequest.GameId))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ namespace CloudGaming.Code.Contract
|
||||||
/// <param name="playGameQueue"></param>
|
/// <param name="playGameQueue"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Post("/jyapi/playQueue")]
|
[Post("/jyapi/playQueue")]
|
||||||
Task<JYApiResponse<Dictionary<string, object>>> PlayGame([Body(BodySerializationMethod.UrlEncoded)] PlayGameQueue playGameQueue);
|
Task<JYApiResponse<PlayQueueInfoModel>> PlayQueue([Body(BodySerializationMethod.UrlEncoded)] PlayGameQueue playGameQueue);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 取消排队
|
/// 取消排队
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
using CloudGaming.Code.AppExtend.ConfigModel;
|
using CloudGaming.Code.AppExtend.ConfigModel;
|
||||||
using CloudGaming.Code.Contract;
|
using CloudGaming.Code.Contract;
|
||||||
|
using CloudGaming.DtoModel.Game;
|
||||||
using CloudGaming.DtoModel.JY;
|
using CloudGaming.DtoModel.JY;
|
||||||
using CloudGaming.DtoModel.PlayGame;
|
using CloudGaming.DtoModel.PlayGame;
|
||||||
|
|
||||||
|
using HuanMeng.DotNetCore.Redis;
|
||||||
|
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
|
@ -57,111 +62,258 @@ namespace CloudGaming.Code.Game
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
/// 启动游戏方法
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="playGameRequest"></param>
|
/// <param name="playGameRequest">启动游戏的请求参数</param>
|
||||||
/// <returns></returns>
|
/// <returns>包含操作结果的响应对象</returns>
|
||||||
public async Task<BaseResponse<object>> PlayGameAsync(PlayGameRequest playGameRequest)
|
public async Task<BaseResponse<object>> PlayGameAsync(PlayGameRequest playGameRequest)
|
||||||
{
|
{
|
||||||
|
// 检查用户是否已登录
|
||||||
if (_UserId == 0)
|
if (_UserId == 0)
|
||||||
{
|
{
|
||||||
throw MessageBox.ErrorShow("请先登录");
|
throw MessageBox.ErrorShow("请先登录");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查游戏是否存在
|
||||||
var gameCache = Cache.GameEntityCache;
|
var gameCache = Cache.GameEntityCache;
|
||||||
var gameInfo = gameCache[playGameRequest.GameId];
|
var gameInfo = gameCache[playGameRequest.GameId];
|
||||||
if (gameInfo == null)
|
if (gameInfo == null)
|
||||||
{
|
{
|
||||||
throw MessageBox.ErrorShow("游戏不存在");
|
throw MessageBox.ErrorShow("游戏不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查用户钻石是否足够
|
||||||
if (UserInfo.Diamond <= 0)
|
if (UserInfo.Diamond <= 0)
|
||||||
{
|
{
|
||||||
throw MessageBox.Show(ResponseCode.NotMoney, "钻石不足");
|
throw MessageBox.Show(ResponseCode.NotMoney, "钻石不足");
|
||||||
}
|
}
|
||||||
var gameId = playGameRequest.GameId;
|
|
||||||
var modelName = playGameRequest.ModelName;
|
// 获取用户和游戏信息
|
||||||
var cpu = playGameRequest.Cpu;
|
var userInfo = UserInfo;
|
||||||
var userGame = await Dao.DaoPhone.Context.T_User_GameList.Where(it => (it.Status == (int)PlayGameStatus.游戏中 || it.Status == (int)PlayGameStatus.排队中) && it.UserId == _UserId).FirstOrDefaultAsync();
|
PlayGameUserInfo gameInfoCache = await PlayGameExtend.GetPlayGameUserInfoCacheAsync(this, userInfo, gameInfo);
|
||||||
if (userGame != null && userGame.Status == (int)PlayGameStatus.游戏中)
|
|
||||||
|
// 检查游戏状态
|
||||||
|
if (gameInfoCache != null)
|
||||||
{
|
{
|
||||||
throw MessageBox.Show(ResponseCode.Error, "已在游戏中");
|
switch (gameInfoCache.GameStatus)
|
||||||
}
|
|
||||||
if (userGame != null && userGame?.Status == (int)PlayGameStatus.排队中)
|
|
||||||
{
|
|
||||||
if (userGame.GameId == gameId)
|
|
||||||
{
|
{
|
||||||
throw MessageBox.Show(ResponseCode.Error, "已经在排队中");
|
case PlayGameStatus.游戏中:
|
||||||
}
|
case PlayGameStatus.开始游戏:
|
||||||
else
|
throw MessageBox.Show(ResponseCode.Error, "已在游戏中");
|
||||||
{
|
|
||||||
userGame.Status = (int)PlayGameStatus.取消排队;
|
case PlayGameStatus.排队中:
|
||||||
await Dao.DaoPhone.Context.SaveChangesAsync();
|
throw MessageBox.Show(ResponseCode.Error, "用户正在排队中");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlayGameSettings playGameSettings = new PlayGameSettings(playGameRequest.Sn, _UserId);
|
|
||||||
playGameSettings.GameKey = gameInfo.GameCloudId ?? gameId;
|
// 配置启动游戏设置
|
||||||
if (UserInfo.IsPay)
|
var playGameSettings = new PlayGameSettings(playGameRequest.Sn, _UserId)
|
||||||
{
|
{
|
||||||
playGameSettings.QueueGrade = 5;
|
GameKey = gameInfo.GameCloudId ?? playGameRequest.GameId,
|
||||||
}
|
QueueGrade = UserInfo.IsPay ? 5 : 1,
|
||||||
playGameSettings.HangUpTimer = 60 * 5;
|
DisplayGrade = 1,
|
||||||
playGameSettings.ModelName = modelName;
|
HangUpTimer = 300, // 挂机时间 5 分钟
|
||||||
playGameSettings.StartResolution = "1080P";
|
ModelName = playGameRequest.ModelName,
|
||||||
playGameRequest.Cpu = cpu;
|
StartResolution = "1080P",
|
||||||
|
};
|
||||||
|
playGameRequest.Cpu = playGameRequest.Cpu;
|
||||||
|
|
||||||
|
// 调用游戏启动接口
|
||||||
var data = await JYApi.PlayGame(playGameSettings);
|
var data = await JYApi.PlayGame(playGameSettings);
|
||||||
T_User_GameList t_User_GameList = new T_User_GameList()
|
|
||||||
{
|
// 创建游戏启动日志对象
|
||||||
Channel = this.AppRequestInfo.Channel,
|
var playGameLog = new T_User_PlayGmaeLog
|
||||||
CreateTime = DateTime.Now,
|
|
||||||
GameId = gameId,
|
|
||||||
PlaySeconds = 0,
|
|
||||||
PlayTime = 0,
|
|
||||||
Status = (int)PlayGameStatus.游戏中,
|
|
||||||
UpdateTime = DateTime.Now,
|
|
||||||
UserId = _UserId,
|
|
||||||
};
|
|
||||||
T_User_GameLog t_User_GameLog = new T_User_GameLog()
|
|
||||||
{
|
|
||||||
Cpu = cpu,
|
|
||||||
CreateTime = DateTime.Now,
|
|
||||||
DisplayGrade = 0,
|
|
||||||
GameId = gameId,
|
|
||||||
Gamekey = gameInfo.GameCloudId,
|
|
||||||
IP = this.HttpContextAccessor.HttpContext.GetClientIpAddress(),
|
|
||||||
ModelName = modelName,
|
|
||||||
PlayQueueId = 0,
|
|
||||||
PlayQueueStatus = 0,
|
|
||||||
QueueGrade = 0,
|
|
||||||
ScId = "",
|
|
||||||
Status = 0,
|
|
||||||
UpdateTime = DateTime.Now,
|
|
||||||
UserId = _UserId,
|
|
||||||
UserKey = "",
|
|
||||||
};
|
|
||||||
T_User_PlayGmaeLog playGmaeLog = new T_User_PlayGmaeLog()
|
|
||||||
{
|
{
|
||||||
CreateTime = DateTime.Now,
|
CreateTime = DateTime.Now,
|
||||||
DescribeContent = $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}用户启动游戏;",
|
DescribeContent = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss} 用户尝试启动游戏;",
|
||||||
GameId = gameId,
|
GameId = playGameRequest.GameId,
|
||||||
UserId = _UserId,
|
UserId = _UserId,
|
||||||
|
RequestContent = data.RequestStr,
|
||||||
|
ResponseContent = data.ResponseStr,
|
||||||
|
SessionId = gameInfoCache?.SessionId
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var response = new BaseResponse<object>();
|
||||||
|
// 用户进入排队
|
||||||
if (data.IsLineUp)
|
if (data.IsLineUp)
|
||||||
{
|
{
|
||||||
playGmaeLog.DescribeContent += $"用户开始排队;";
|
var gameResponse = JsonConvert.DeserializeObject<JYResponseCode<PlayQueueInfoModel>>(data.ResponseContent);
|
||||||
t_User_GameList.Status = (int)PlayGameStatus.排队中;
|
|
||||||
await Dao.DaoPhone.Context.AddAsync(t_User_GameList);
|
gameInfoCache?.PlayQueueStart(gameResponse?.Data?.PlayQueueId ?? 0, gameResponse?.Data?.QueuePos ?? 0, playGameSettings.QueueGrade);
|
||||||
await Dao.DaoPhone.Context.SaveChangesAsync();
|
playGameLog.DescribeContent += "用户进入排队状态;";
|
||||||
return new BaseResponse<object>(ResponseCode.StartQueue, "开始排队", data.Data);
|
response = new BaseResponse<object>(ResponseCode.StartQueue, "开始排队", data.Data);
|
||||||
}
|
}
|
||||||
else if (data.IsSuccess)
|
else if (data.IsSuccess)
|
||||||
{
|
{
|
||||||
playGmaeLog.DescribeContent += $"用户启动游戏成功;";
|
// 游戏启动成功
|
||||||
await Dao.DaoPhone.Context.AddAsync(t_User_GameList);
|
var gameResponse = JsonConvert.DeserializeObject<JYResponseCode<JYPlayGameModel>>(data.ResponseContent);
|
||||||
|
|
||||||
|
// 创建游戏记录和日志
|
||||||
|
var userGameList = new T_User_GameList
|
||||||
|
{
|
||||||
|
Channel = AppRequestInfo.Channel,
|
||||||
|
CreateTime = DateTime.Now,
|
||||||
|
GameId = playGameRequest.GameId,
|
||||||
|
Status = (int)PlayGameStatus.开始游戏,
|
||||||
|
UpdateTime = DateTime.Now,
|
||||||
|
UserId = _UserId
|
||||||
|
};
|
||||||
|
|
||||||
|
var userGameLog = new T_User_GameLog
|
||||||
|
{
|
||||||
|
Cpu = playGameRequest.Cpu,
|
||||||
|
CreateTime = DateTime.Now,
|
||||||
|
DisplayGrade = playGameSettings.DisplayGrade,
|
||||||
|
GameId = playGameRequest.GameId,
|
||||||
|
Gamekey = gameInfo.GameCloudId,
|
||||||
|
IP = HttpContextAccessor.HttpContext.GetClientIpAddress(),
|
||||||
|
ModelName = playGameRequest.ModelName,
|
||||||
|
QueueGrade = playGameSettings.QueueGrade,
|
||||||
|
ScId = gameResponse?.Data?.ScId ?? "",
|
||||||
|
Status = (int)PlayGameStatus.开始游戏,
|
||||||
|
UpdateTime = DateTime.Now,
|
||||||
|
UserId = _UserId,
|
||||||
|
UserKey = gameResponse?.Data?.UserKey ?? "",
|
||||||
|
SessionId = gameInfoCache?.SessionId
|
||||||
|
};
|
||||||
|
|
||||||
|
playGameLog.DescribeContent += "游戏启动成功;";
|
||||||
|
|
||||||
|
// 保存数据
|
||||||
|
await Dao.DaoPhone.Context.T_User_GameLog.AddAsync(userGameLog);
|
||||||
|
await Dao.DaoPhone.Context.T_User_GameList.AddAsync(userGameList);
|
||||||
await Dao.DaoPhone.Context.SaveChangesAsync();
|
await Dao.DaoPhone.Context.SaveChangesAsync();
|
||||||
return new BaseResponse<object>(ResponseCode.Success, "", data.Data);
|
|
||||||
|
gameInfoCache?.PlayGameStart(userGameLog.ScId, userGameList.Id, playGameSettings.DisplayGrade);
|
||||||
|
response = new BaseResponse<object>(ResponseCode.Success, "", data.Data);
|
||||||
}
|
}
|
||||||
playGmaeLog.DescribeContent += $"用户游戏启动失败;";
|
else // 游戏启动失败
|
||||||
return new BaseResponse<object>(ResponseCode.Error, data.Msg, data.Data);
|
{
|
||||||
|
gameInfoCache?.PlayGameError();
|
||||||
|
playGameLog.DescribeContent += "游戏启动失败;";
|
||||||
|
response = new BaseResponse<object>(ResponseCode.Error, data.Msg, data.Data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存日志
|
||||||
|
await Dao.DaoPhone.Context.T_User_PlayGmaeLog.AddAsync(playGameLog);
|
||||||
|
await Dao.DaoPhone.Context.SaveChangesAsync();
|
||||||
|
|
||||||
|
// 保存游戏缓存状态
|
||||||
|
await gameInfoCache.SaveChangesAsync(this);
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 游戏排队
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="gameRequest"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<BaseResponse<PlayQueueInfoModel>> PlayGameQueue(GameRequest gameRequest)
|
||||||
|
{
|
||||||
|
if (_UserId == 0)
|
||||||
|
{
|
||||||
|
throw MessageBox.ErrorShow("请先登录");
|
||||||
|
}
|
||||||
|
var gameId = gameRequest.GameId;
|
||||||
|
// 检查游戏是否存在
|
||||||
|
var gameCache = Cache.GameEntityCache;
|
||||||
|
var gameInfo = gameCache[gameId];
|
||||||
|
if (gameInfo == null)
|
||||||
|
{
|
||||||
|
throw MessageBox.ErrorShow("游戏不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取用户和游戏信息
|
||||||
|
var userInfo = UserInfo;
|
||||||
|
PlayGameUserInfo gameInfoCache = await PlayGameExtend.GetPlayGameUserInfoOrNull(this, userInfo, gameInfo);
|
||||||
|
if (gameInfoCache == null)
|
||||||
|
{
|
||||||
|
throw MessageBox.ErrorShow("未找到排队信息");
|
||||||
|
}
|
||||||
|
if (gameInfoCache.PlayQueueId == 0)
|
||||||
|
{
|
||||||
|
throw MessageBox.ErrorShow("排队出错");
|
||||||
|
}
|
||||||
|
PlayGameQueue playGameQueue = new PlayGameQueue()
|
||||||
|
{
|
||||||
|
GameKey = gameInfoCache.JyGameId,
|
||||||
|
PlayQueueId = gameInfoCache.PlayQueueId,
|
||||||
|
QueueGrade = gameInfoCache.QueueGrade,
|
||||||
|
Sn = gameInfoCache.Sn,
|
||||||
|
};
|
||||||
|
var paidui = await JYApi.PlayQueue(playGameQueue);
|
||||||
|
BaseResponse<PlayQueueInfoModel> back = new BaseResponse<PlayQueueInfoModel>();
|
||||||
|
if (paidui.IsSuccess)
|
||||||
|
{
|
||||||
|
gameInfoCache.PlayQueueSuccess();
|
||||||
|
back = new BaseResponse<PlayQueueInfoModel>(0, "排队成功");
|
||||||
|
}
|
||||||
|
else if (paidui.IsLineUp)
|
||||||
|
{
|
||||||
|
gameInfoCache.PlayQueueStart(paidui?.Data?.PlayQueueId ?? 0, paidui?.Data?.QueuePos ?? 0);
|
||||||
|
back = new BaseResponse<PlayQueueInfoModel>(ResponseCode.StartQueue, "", paidui.Data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gameInfoCache.PlayGameError();
|
||||||
|
back = new BaseResponse<PlayQueueInfoModel>(ResponseCode.Error, "排队出现错误", paidui.Data);
|
||||||
|
}
|
||||||
|
|
||||||
|
await gameInfoCache.SaveChangesAsync(this);
|
||||||
|
return back;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 取消排队
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="gameRequest"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<BaseResponse<bool>> CancelQueue(GameRequest gameRequest)
|
||||||
|
{
|
||||||
|
if (_UserId == 0)
|
||||||
|
{
|
||||||
|
throw MessageBox.ErrorShow("请先登录");
|
||||||
|
}
|
||||||
|
var gameId = gameRequest.GameId;
|
||||||
|
// 检查游戏是否存在
|
||||||
|
var gameCache = Cache.GameEntityCache;
|
||||||
|
var gameInfo = gameCache[gameId];
|
||||||
|
if (gameInfo == null)
|
||||||
|
{
|
||||||
|
throw MessageBox.ErrorShow("游戏不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取用户和游戏信息
|
||||||
|
var userInfo = UserInfo;
|
||||||
|
PlayGameUserInfo gameInfoCache = await PlayGameExtend.GetPlayGameUserInfoOrNull(this, userInfo, gameInfo);
|
||||||
|
if (gameInfoCache == null)
|
||||||
|
{
|
||||||
|
throw MessageBox.ErrorShow("未找到排队信息");
|
||||||
|
}
|
||||||
|
if (gameInfoCache.PlayQueueId == 0)
|
||||||
|
{
|
||||||
|
throw MessageBox.ErrorShow("排队出错");
|
||||||
|
}
|
||||||
|
//CancelQueue
|
||||||
|
//PlayGameCancelQueue playGameQueue
|
||||||
|
PlayGameQueue playGameQueue = new PlayGameQueue()
|
||||||
|
{
|
||||||
|
PlayQueueId = gameInfoCache.PlayQueueId,
|
||||||
|
Sn = gameInfoCache.Sn,
|
||||||
|
};
|
||||||
|
var paidui = await JYApi.CancelQueue(playGameQueue);
|
||||||
|
if (paidui.IsSuccess)
|
||||||
|
{
|
||||||
|
gameInfoCache.PlayQueueCancel();
|
||||||
|
}
|
||||||
|
await gameInfoCache.SaveChangesAsync(this);
|
||||||
|
return new BaseResponse<bool>(ResponseCode.Success, "取消排队成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<BaseResponse<object> DisplayGrade(int queue_grade)
|
||||||
|
{
|
||||||
|
return new BaseResponse<object>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,44 +1,220 @@
|
||||||
|
using CloudGaming.DtoModel.Account.User;
|
||||||
|
using CloudGaming.DtoModel.Game;
|
||||||
|
using CloudGaming.DtoModel.JY;
|
||||||
using CloudGaming.DtoModel.PlayGame;
|
using CloudGaming.DtoModel.PlayGame;
|
||||||
|
|
||||||
using System;
|
using HuanMeng.DotNetCore.Redis;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CloudGaming.Code.Game
|
namespace CloudGaming.Code.Game
|
||||||
{
|
{
|
||||||
public static class PlayGameExtend
|
public static class PlayGameExtend
|
||||||
{
|
{
|
||||||
|
private static string GetPlayGameKey(string gameId, int userId) => $"PlayGame:{gameId}:{userId}";
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
/// 获取用户游戏缓存
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="requestBaseModel"></param>
|
/// <param name="cloudGamingBase"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
|
/// <param name="gameInfo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static async Task<PlayGameUserInfo> GetPlayGameUserInfoCacheAsync(CloudGamingBase cloudGamingBase, UserInfo userInfo, GameInfo gameInfo)
|
||||||
|
{
|
||||||
|
var redisGameKey = GetPlayGameKey(gameInfo.GameId, userInfo.UserId);
|
||||||
|
var gameInfoCache = await cloudGamingBase.RedisCache.StringGetAsync<PlayGameUserInfo>(redisGameKey);
|
||||||
|
if (gameInfoCache == null)
|
||||||
|
{
|
||||||
|
gameInfoCache = new PlayGameUserInfo()
|
||||||
|
{
|
||||||
|
GameId = gameInfo.GameId,
|
||||||
|
GameName = gameInfo.GameName,
|
||||||
|
GameStatus = PlayGameStatus.初始化,
|
||||||
|
CreateDateTime = DateTime.Now,
|
||||||
|
GameUserOperation = new List<PlayGameUserOperation>(),
|
||||||
|
UserId = userInfo.UserId,
|
||||||
|
UserPlayGameDiamonds = userInfo.Diamond,
|
||||||
|
SessionId = Guid.NewGuid().ToString("N"),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return gameInfoCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取用户游戏缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cloudGamingBase"></param>
|
||||||
|
/// <param name="userInfo"></param>
|
||||||
|
/// <param name="gameInfo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static async Task<PlayGameUserInfo> GetPlayGameUserInfoOrNull(CloudGamingBase cloudGamingBase, UserInfo userInfo, GameInfo gameInfo)
|
||||||
|
{
|
||||||
|
var redisGameKey = GetPlayGameKey(gameInfo.GameId, userInfo.UserId);
|
||||||
|
var gameInfoCache = await cloudGamingBase.RedisCache.StringGetAsync<PlayGameUserInfo>(redisGameKey);
|
||||||
|
return gameInfoCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="playGameUserInfo"></param>
|
||||||
|
/// <param name="sn"></param>
|
||||||
|
/// <param name="modenName"></param>
|
||||||
|
/// <param name="cpu"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool InitStartPlayGame(this PlayGameUserInfo playGameUserInfo, string sn, string modenName, string cpu)
|
||||||
|
{
|
||||||
|
playGameUserInfo.Sn = sn;
|
||||||
|
playGameUserInfo.Cpu = cpu;
|
||||||
|
playGameUserInfo.ModelName = modenName;
|
||||||
|
if (playGameUserInfo.GameStatus == PlayGameStatus.初始化)
|
||||||
|
{
|
||||||
|
playGameUserInfo.GameStatus = PlayGameStatus.初始化成功;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 开始游戏
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="playGameUserInfo"></param>
|
||||||
|
/// <param name="scId">本次游戏连接会话 id</param>
|
||||||
|
/// <param name="gameListId">游戏记录id</param>
|
||||||
|
/// <param name="display_grade">游戏显示等级</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool PlayGameStart(this PlayGameUserInfo playGameUserInfo, string scId, int gameListId, int display_grade)
|
||||||
|
{
|
||||||
|
playGameUserInfo.GameStatus = PlayGameStatus.开始游戏;
|
||||||
|
playGameUserInfo.GameListId = gameListId;
|
||||||
|
playGameUserInfo.ScId = scId;
|
||||||
|
playGameUserInfo.DisplayGrade = display_grade;
|
||||||
|
playGameUserInfo.GameUserOperation.Add(new PlayGameUserOperation()
|
||||||
|
{
|
||||||
|
Content = "开始游戏",
|
||||||
|
OperationDateTime = DateTime.Now,
|
||||||
|
});
|
||||||
|
playGameUserInfo.PlayGameStartAt = DateTime.Now;
|
||||||
|
playGameUserInfo.PlayGameHeartbeatAt = DateTime.Now;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 游戏启动失败
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="playGameUserInfo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool PlayGameError(this PlayGameUserInfo playGameUserInfo)
|
||||||
|
{
|
||||||
|
playGameUserInfo.GameStatus = PlayGameStatus.游戏启动失败;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 游戏心跳
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="playGameUserInfo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool PlayGameHeartbeat(this PlayGameUserInfo playGameUserInfo)
|
||||||
|
{
|
||||||
|
|
||||||
|
playGameUserInfo.GameStatus = PlayGameStatus.游戏中;
|
||||||
|
playGameUserInfo.PlayGameHeartbeatAt = DateTime.Now;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 开始排队
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="playGameUserInfo"></param>
|
||||||
|
/// <param name="play_queue_id">队列id</param>
|
||||||
|
/// <param name="queue_pos">前面还有多少位</param>
|
||||||
|
/// <param name="queue_grade">队列等级</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool PlayQueueStart(this PlayGameUserInfo playGameUserInfo, int play_queue_id, int queue_pos, int? queue_grade = null)
|
||||||
|
{
|
||||||
|
if (playGameUserInfo.GameStatus == PlayGameStatus.排队中)
|
||||||
|
{
|
||||||
|
playGameUserInfo.GameUserOperation.Add(new PlayGameUserOperation()
|
||||||
|
{
|
||||||
|
Content = $"排队中,前面还有{queue_pos}人",
|
||||||
|
OperationDateTime = DateTime.Now,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
playGameUserInfo.GameUserOperation.Add(new PlayGameUserOperation()
|
||||||
|
{
|
||||||
|
Content = $"开始排队,前面还有{queue_pos}人",
|
||||||
|
OperationDateTime = DateTime.Now,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
playGameUserInfo.GameStatus = PlayGameStatus.排队中;
|
||||||
|
playGameUserInfo.PlayQueueId = play_queue_id;
|
||||||
|
|
||||||
|
playGameUserInfo.PlayQueueStartAt = DateTime.Now;
|
||||||
|
if (queue_grade != null)
|
||||||
|
{
|
||||||
|
playGameUserInfo.QueueGrade = queue_grade ?? 1;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 排队成功
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="playGameUserInfo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool PlayQueueSuccess(this PlayGameUserInfo playGameUserInfo)
|
||||||
|
{
|
||||||
|
if (playGameUserInfo.GameStatus == PlayGameStatus.排队中)
|
||||||
|
{
|
||||||
|
playGameUserInfo.GameStatus = PlayGameStatus.排队成功;
|
||||||
|
playGameUserInfo.PlayQueueSuccessAt = DateTime.Now;
|
||||||
|
var totalSeconds = 0;
|
||||||
|
if (playGameUserInfo.PlayQueueStart != null)
|
||||||
|
{
|
||||||
|
totalSeconds = (int)DateTime.Now.Subtract(playGameUserInfo.PlayQueueStartAt ?? DateTime.Now).TotalSeconds;
|
||||||
|
}
|
||||||
|
playGameUserInfo.GameUserOperation.Add(new PlayGameUserOperation()
|
||||||
|
{
|
||||||
|
Content = $"排队成功,本次排队耗时{totalSeconds}秒",
|
||||||
|
OperationDateTime = DateTime.Now,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 取消排队
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="playGameUserInfo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool PlayQueueCancel(this PlayGameUserInfo playGameUserInfo)
|
||||||
|
{
|
||||||
|
playGameUserInfo.GameStatus = PlayGameStatus.取消排队;
|
||||||
|
playGameUserInfo.GameUserOperation.Add(new PlayGameUserOperation()
|
||||||
|
{
|
||||||
|
Content = $"用户取消排队",
|
||||||
|
OperationDateTime = DateTime.Now,
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存缓存到redis中
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="playGameUserInfo">用户玩游戏信息</param>
|
||||||
/// <param name="cloudGamingBase"></param>
|
/// <param name="cloudGamingBase"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static SortedDictionary<string, object> GetDefaultParams(this RequestBaseModel requestBaseModel, CloudGamingBase cloudGamingBase)
|
public static async Task<bool> SaveChangesAsync(this PlayGameUserInfo playGameUserInfo, CloudGamingBase cloudGamingBase)
|
||||||
{
|
{
|
||||||
|
var redisGameKey = GetPlayGameKey(playGameUserInfo.GameId, playGameUserInfo.UserId);
|
||||||
|
if (playGameUserInfo.GameStatus == PlayGameStatus.取消排队 || playGameUserInfo.GameStatus == PlayGameStatus.游戏启动失败)
|
||||||
|
{
|
||||||
|
return await cloudGamingBase.RedisCache.KeyDeleteAsync(redisGameKey);
|
||||||
|
|
||||||
|
}
|
||||||
|
return await cloudGamingBase.RedisCache.StringSetAsync(redisGameKey, playGameUserInfo, TimeSpan.FromMinutes(10));
|
||||||
|
|
||||||
return GetDefaultParams(requestBaseModel, cloudGamingBase.AppConfig.GameConfig, cloudGamingBase.HttpContextAccessor.HttpContext.GetClientIpAddress(), cloudGamingBase._UserId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="requestBaseModel"></param>
|
|
||||||
/// <param name="gameConfig"></param>
|
|
||||||
/// <param name="ip"></param>
|
|
||||||
/// <param name="UserId"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static SortedDictionary<string, object> GetDefaultParams(this RequestBaseModel requestBaseModel, GameConfig gameConfig, string ip, int UserId)
|
|
||||||
{
|
|
||||||
var dicParams = new SortedDictionary<string, object>();
|
|
||||||
dicParams.Add("channel_id", gameConfig.ChannelId);
|
|
||||||
dicParams.Add("sn", requestBaseModel.Sn);
|
|
||||||
dicParams.Add("client_sid", UserId);
|
|
||||||
dicParams.Add("ip", ip);
|
|
||||||
dicParams.Add("time", DateTimeOffset.UtcNow.ToUnixTimeSeconds());
|
|
||||||
return dicParams;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
using CloudGaming.DtoModel.PlayGame;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace CloudGaming.Code.Game
|
||||||
|
{
|
||||||
|
public class PlayGameUserInfoCache
|
||||||
|
{
|
||||||
|
private string redisGameKey;
|
||||||
|
public PlayGameUserInfoCache(CloudGamingBase cloudGamingBase, string gameId, string userId)
|
||||||
|
{
|
||||||
|
redisGameKey = $"PlayGame:{gameId}:{userId}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -21,4 +21,5 @@ global using Microsoft.Extensions.DependencyInjection;
|
||||||
global using Microsoft.Extensions.Hosting;
|
global using Microsoft.Extensions.Hosting;
|
||||||
global using System.Diagnostics;
|
global using System.Diagnostics;
|
||||||
|
|
||||||
global using CloudGaming.Code.AppExtend.ConfigModel;
|
global using CloudGaming.Code.AppExtend.ConfigModel;
|
||||||
|
global using HuanMeng.DotNetCore.Redis;
|
||||||
|
|
@ -122,6 +122,7 @@ public class JYApiHandler : DelegatingHandler
|
||||||
responseJson["RequestStr"] = await request.ToJsonAsync();
|
responseJson["RequestStr"] = await request.ToJsonAsync();
|
||||||
responseJson["ResponseStr"] = SerializeResponse(response, responseContent);
|
responseJson["ResponseStr"] = SerializeResponse(response, responseContent);
|
||||||
responseJson["TotalMilliseconds"] = totalMilliseconds;
|
responseJson["TotalMilliseconds"] = totalMilliseconds;
|
||||||
|
responseJson["ResponseContent"] = responseContent;
|
||||||
|
|
||||||
var newContent = new StringContent(JsonConvert.SerializeObject(responseJson), Encoding.UTF8, "application/json");
|
var newContent = new StringContent(JsonConvert.SerializeObject(responseJson), Encoding.UTF8, "application/json");
|
||||||
response.Content = newContent;
|
response.Content = newContent;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ namespace CloudGaming.DtoModel.Game
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 游戏收藏
|
/// 游戏收藏
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class GameCollectRequest
|
public class GameRequest
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 游戏Id
|
/// 游戏Id
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace CloudGaming.DtoModel.JY;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 切换视频等级
|
||||||
|
/// </summary>
|
||||||
|
public class DisplayGradeModel
|
||||||
|
{
|
||||||
|
[JsonProperty("level_config")]
|
||||||
|
public string LevelConfig { get; set; }
|
||||||
|
}
|
||||||
|
|
@ -23,6 +23,11 @@ namespace CloudGaming.DtoModel.JY
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ResponseStr { get; set; }
|
public string ResponseStr { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返回内容
|
||||||
|
/// </summary>
|
||||||
|
public string ResponseContent { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 请求耗时
|
/// 请求耗时
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace CloudGaming.DtoModel.JY
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 鲸云返回的实体类
|
||||||
|
/// </summary>
|
||||||
|
public class JYPlayGameModel
|
||||||
|
{
|
||||||
|
public JYPlayGameModel()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 用户 id
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("sn_user_id")]
|
||||||
|
public string SnUserId { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 用户标识
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("user_key")]
|
||||||
|
public string UserKey { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 本次游戏连接会话 id
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("sc_id")]
|
||||||
|
public string ScId { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 链路唯一标识,
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("gl_key")]
|
||||||
|
public string GlKey { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace CloudGaming.DtoModel.JY;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 排队信息
|
||||||
|
/// </summary>
|
||||||
|
public class PlayQueueInfoModel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 排队id
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("play_queue_id")]
|
||||||
|
public int PlayQueueId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 前面还有多少人
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("queue_pos")]
|
||||||
|
public int QueuePos { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -28,5 +28,5 @@ public class PlayGameQueue : RequestBaseModel
|
||||||
/// 队列等级,默认 1
|
/// 队列等级,默认 1
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonPropertyName("queue_grade")]
|
[JsonPropertyName("queue_grade")]
|
||||||
public int QueueGrade { get; set; } = 1; // 默认值为 1
|
public int QueueGrade { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace CloudGaming.DtoModel.PlayGame
|
||||||
|
{
|
||||||
|
public class PlayGameQueueRequest
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -35,13 +35,13 @@ namespace CloudGaming.DtoModel.PlayGame
|
||||||
/// 显示等级,可在后台配置,默认为 1
|
/// 显示等级,可在后台配置,默认为 1
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonPropertyName("display_grade")]
|
[JsonPropertyName("display_grade")]
|
||||||
public int? DisplayGrade { get; set; }
|
public int DisplayGrade { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 队列等级,等级越高优先级越高, 默认 1
|
/// 队列等级,等级越高优先级越高, 默认 1
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonPropertyName("queue_grade")]
|
[JsonPropertyName("queue_grade")]
|
||||||
public int? QueueGrade { get; set; }
|
public int QueueGrade { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 服务器等级,只使用相同等级的资源,默认 0,不限定资源
|
/// 服务器等级,只使用相同等级的资源,默认 0,不限定资源
|
||||||
|
|
|
||||||
|
|
@ -12,24 +12,45 @@ namespace CloudGaming.DtoModel.PlayGame
|
||||||
public enum PlayGameStatus
|
public enum PlayGameStatus
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
/// 正常
|
||||||
/// </summary>
|
/// </summary>
|
||||||
正常 = 0,
|
初始化 = 0,
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化成功
|
||||||
|
/// </summary>
|
||||||
|
初始化成功 = 1,
|
||||||
|
/// <summary>
|
||||||
|
/// 开始游戏
|
||||||
|
/// </summary>
|
||||||
|
开始游戏 = 2,
|
||||||
|
/// <summary>
|
||||||
|
/// 游戏中
|
||||||
|
/// </summary>
|
||||||
|
游戏中 = 3,
|
||||||
|
/// <summary>
|
||||||
|
/// 游戏结束
|
||||||
|
/// </summary>
|
||||||
|
游戏结束 = 4,
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
游戏中 = 1,
|
排队中 = 5,
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
排队中 = 2,
|
排队成功 = 6,
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
游戏结束 = 3,
|
取消排队 = 7,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
/// 游戏掉线
|
||||||
/// </summary>
|
/// </summary>
|
||||||
取消排队 = 4
|
游戏掉线 = 8,
|
||||||
|
/// <summary>
|
||||||
|
/// 游戏启动失败
|
||||||
|
/// </summary>
|
||||||
|
游戏启动失败 = 9
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,122 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace CloudGaming.DtoModel.PlayGame
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 游戏
|
||||||
|
/// </summary>
|
||||||
|
public class PlayGameUserInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 游戏Id
|
||||||
|
/// </summary>
|
||||||
|
public string GameId { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 游戏名称
|
||||||
|
/// </summary>
|
||||||
|
public string GameName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户剩余钻石
|
||||||
|
/// </summary>
|
||||||
|
public int UserPlayGameDiamonds { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户本次玩游戏共花销多少钻石
|
||||||
|
/// </summary>
|
||||||
|
public int SpendingDiamonds { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户Id
|
||||||
|
/// </summary>
|
||||||
|
public int UserId { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 创建时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime CreateDateTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 最后一次修改时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime LastDateTime { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 开始游戏时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime PlayGameStartAt { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 游戏心跳时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime PlayGameHeartbeatAt { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 游戏记录id
|
||||||
|
/// </summary>
|
||||||
|
public int GameListId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户设备号
|
||||||
|
/// </summary>
|
||||||
|
public string Sn { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 设备号
|
||||||
|
/// </summary>
|
||||||
|
public string SessionId { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 设备型号
|
||||||
|
/// </summary>
|
||||||
|
public string ModelName { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 用户cpu
|
||||||
|
/// </summary>
|
||||||
|
public string Cpu { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 鲸云scid
|
||||||
|
/// </summary>
|
||||||
|
public string ScId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 第三方游戏id
|
||||||
|
/// </summary>
|
||||||
|
public string JyGameId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 显示等级
|
||||||
|
/// </summary>
|
||||||
|
public int DisplayGrade { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 队列等级
|
||||||
|
/// </summary>
|
||||||
|
public int QueueGrade { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户游戏状态
|
||||||
|
/// </summary>
|
||||||
|
public PlayGameStatus GameStatus { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户排队Id
|
||||||
|
/// </summary>
|
||||||
|
public int PlayQueueId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户开始排队时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? PlayQueueStartAt { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 结束排队时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? PlayQueueSuccessAt { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户操作内容
|
||||||
|
/// </summary>
|
||||||
|
public List<PlayGameUserOperation> GameUserOperation { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace CloudGaming.DtoModel.PlayGame
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 用户玩游戏时操作
|
||||||
|
/// </summary>
|
||||||
|
public class PlayGameUserOperation
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 操作时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime OperationDateTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 操作内容
|
||||||
|
/// </summary>
|
||||||
|
public string Content { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1142,7 +1142,7 @@ public partial class CloudGamingPhoneContext : MultiTenantDbContext//DbContext
|
||||||
entity.ToTable(tb => tb.HasComment("游戏日志表"));
|
entity.ToTable(tb => tb.HasComment("游戏日志表"));
|
||||||
|
|
||||||
entity.Property(e => e.Cpu)
|
entity.Property(e => e.Cpu)
|
||||||
.HasMaxLength(1)
|
.HasMaxLength(50)
|
||||||
.HasComment("设备cpu");
|
.HasComment("设备cpu");
|
||||||
entity.Property(e => e.CreateTime)
|
entity.Property(e => e.CreateTime)
|
||||||
.HasComment("开始时间")
|
.HasComment("开始时间")
|
||||||
|
|
@ -1158,7 +1158,7 @@ public partial class CloudGamingPhoneContext : MultiTenantDbContext//DbContext
|
||||||
.HasMaxLength(64)
|
.HasMaxLength(64)
|
||||||
.HasComment("ip");
|
.HasComment("ip");
|
||||||
entity.Property(e => e.ModelName)
|
entity.Property(e => e.ModelName)
|
||||||
.HasMaxLength(1)
|
.HasMaxLength(50)
|
||||||
.HasComment("设备型号");
|
.HasComment("设备型号");
|
||||||
entity.Property(e => e.PlayQueueId).HasComment("游戏排队id");
|
entity.Property(e => e.PlayQueueId).HasComment("游戏排队id");
|
||||||
entity.Property(e => e.PlayQueueStatus).HasComment("排队状态");
|
entity.Property(e => e.PlayQueueStatus).HasComment("排队状态");
|
||||||
|
|
@ -1166,6 +1166,9 @@ public partial class CloudGamingPhoneContext : MultiTenantDbContext//DbContext
|
||||||
entity.Property(e => e.ScId)
|
entity.Property(e => e.ScId)
|
||||||
.HasMaxLength(64)
|
.HasMaxLength(64)
|
||||||
.HasComment("会话Id");
|
.HasComment("会话Id");
|
||||||
|
entity.Property(e => e.SessionId)
|
||||||
|
.HasMaxLength(64)
|
||||||
|
.HasComment("会话id");
|
||||||
entity.Property(e => e.Status).HasComment("状态,排队,游戏中,启动失败");
|
entity.Property(e => e.Status).HasComment("状态,排队,游戏中,启动失败");
|
||||||
entity.Property(e => e.TenantId).HasComment("租户");
|
entity.Property(e => e.TenantId).HasComment("租户");
|
||||||
entity.Property(e => e.UpdateTime)
|
entity.Property(e => e.UpdateTime)
|
||||||
|
|
@ -1173,7 +1176,7 @@ public partial class CloudGamingPhoneContext : MultiTenantDbContext//DbContext
|
||||||
.HasColumnType("datetime");
|
.HasColumnType("datetime");
|
||||||
entity.Property(e => e.UserId).HasComment("用户Id");
|
entity.Property(e => e.UserId).HasComment("用户Id");
|
||||||
entity.Property(e => e.UserKey)
|
entity.Property(e => e.UserKey)
|
||||||
.HasMaxLength(1)
|
.HasMaxLength(100)
|
||||||
.HasComment("用户标识");
|
.HasComment("用户标识");
|
||||||
//添加全局筛选器
|
//添加全局筛选器
|
||||||
if (this.TenantInfo != null)
|
if (this.TenantInfo != null)
|
||||||
|
|
@ -1234,6 +1237,9 @@ public partial class CloudGamingPhoneContext : MultiTenantDbContext//DbContext
|
||||||
.HasComment("游戏Id");
|
.HasComment("游戏Id");
|
||||||
entity.Property(e => e.NightCardPlayTime).HasComment("包夜卡游玩时间");
|
entity.Property(e => e.NightCardPlayTime).HasComment("包夜卡游玩时间");
|
||||||
entity.Property(e => e.PlayTime).HasComment("游玩总时间");
|
entity.Property(e => e.PlayTime).HasComment("游玩总时间");
|
||||||
|
entity.Property(e => e.SessionId)
|
||||||
|
.HasMaxLength(64)
|
||||||
|
.HasComment("会话id");
|
||||||
entity.Property(e => e.TenantId).HasComment("租户");
|
entity.Property(e => e.TenantId).HasComment("租户");
|
||||||
entity.Property(e => e.UpdateTime)
|
entity.Property(e => e.UpdateTime)
|
||||||
.HasComment("创建时间")
|
.HasComment("创建时间")
|
||||||
|
|
@ -1260,6 +1266,11 @@ public partial class CloudGamingPhoneContext : MultiTenantDbContext//DbContext
|
||||||
entity.Property(e => e.GameId)
|
entity.Property(e => e.GameId)
|
||||||
.HasMaxLength(50)
|
.HasMaxLength(50)
|
||||||
.HasComment("游戏Id");
|
.HasComment("游戏Id");
|
||||||
|
entity.Property(e => e.RequestContent).HasComment("请求接口内容");
|
||||||
|
entity.Property(e => e.ResponseContent).HasComment("返回内容");
|
||||||
|
entity.Property(e => e.SessionId)
|
||||||
|
.HasMaxLength(64)
|
||||||
|
.HasComment("会话id");
|
||||||
entity.Property(e => e.TenantId).HasComment("租户");
|
entity.Property(e => e.TenantId).HasComment("租户");
|
||||||
entity.Property(e => e.UpdateTime)
|
entity.Property(e => e.UpdateTime)
|
||||||
.HasComment("修改时间")
|
.HasComment("修改时间")
|
||||||
|
|
|
||||||
|
|
@ -90,4 +90,9 @@ public partial class T_User_GameLog: MultiTenantEntity
|
||||||
/// 状态,排队,游戏中,启动失败
|
/// 状态,排队,游戏中,启动失败
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual int Status { get; set; }
|
public virtual int Status { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 会话id
|
||||||
|
/// </summary>
|
||||||
|
public virtual string? SessionId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,4 +55,9 @@ public partial class T_User_PlayGameTime: MultiTenantEntity
|
||||||
/// 所属租户
|
/// 所属租户
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override Guid TenantId { get; set; }
|
public override Guid TenantId { get; set; }
|
||||||
}
|
|
||||||
|
/// <summary>
|
||||||
|
/// 会话id
|
||||||
|
/// </summary>
|
||||||
|
public virtual string? SessionId { get; set; }
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,4 +43,19 @@ public partial class T_User_PlayGmaeLog: MultiTenantEntity
|
||||||
/// 用户id
|
/// 用户id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual int UserId { get; set; }
|
public virtual int UserId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 请求接口内容
|
||||||
|
/// </summary>
|
||||||
|
public virtual string? RequestContent { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返回内容
|
||||||
|
/// </summary>
|
||||||
|
public virtual string? ResponseContent { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 会话id
|
||||||
|
/// </summary>
|
||||||
|
public virtual string? SessionId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user