Compare commits

..

2 Commits

Author SHA1 Message Date
da81d4799a 收藏事件 2025-01-08 23:22:45 +08:00
d05d69735d 收藏fixed,协议更新 部分即时存档 2025-01-08 23:18:21 +08:00
19 changed files with 6015 additions and 145 deletions

View File

@ -29,6 +29,7 @@ namespace AxibugEmuOnline.Client.ClientCore
public static AppRoom roomMgr;
public static AppSettings settings;
public static AppShare share;
private static object gameSavMgr;
static bool bTest;
static string mTestSrvIP;
#region Mono
@ -70,6 +71,7 @@ namespace AxibugEmuOnline.Client.ClientCore
CacheMgr = new CacheManager();
roomMgr = new AppRoom();
share = new AppShare();
gameSavMgr = new AppGameSavMgr();
bTest = isTest;
mTestSrvIP = testSrvIP;
var go = new GameObject("[AppAxibugEmuOnline]");

View File

@ -25,8 +25,6 @@
//更新其他用户信息
OnOtherUserInfoUpdate,
//当收藏数发生变化
OnDoStars,
//用户列表,登录和离开
OnUserListAllUpdate,
@ -90,5 +88,9 @@
/// <para><see cref="int"/>RomID</para>
/// </summary>
OnRomStarStateChanged, //TODO 实现这个事件
/// <summary>
/// 网络即时存档列表更新
/// </summary>
OnNetGameSavListUpdate,
}
}

View File

@ -0,0 +1,133 @@
using AxibugEmuOnline.Client.ClientCore;
using AxibugEmuOnline.Client.Common;
using AxibugEmuOnline.Client.Event;
using AxibugEmuOnline.Client.Network;
using AxibugProtobuf;
using System.Collections.Generic;
using System.Linq;
namespace AxibugEmuOnline.Client.Manager
{
public class AppGameSavMgr
{
Dictionary<int, Protobuf_Mine_GameSavInfo[]> dictRomId2SavInfo = new Dictionary<int, Protobuf_Mine_GameSavInfo[]>();
public AppGameSavMgr()
{
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdGamesavGetGameSavList, RecvGetGameSavList);
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdGamesavDelGameSav, RecvDelGameSavList);
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdGamesavUploadGameSav, RecvUpLoadGameSav);
}
/// <summary>
/// 从数据层取存档列表数据一般是OnNetGameSavListUpdate事件来了之后来取数据
/// </summary>
/// <param name="RomID"></param>
/// <returns></returns>
public Protobuf_Mine_GameSavInfo[] GetRomSaveIDList(int RomID)
{
if (!dictRomId2SavInfo.ContainsKey(RomID))
{
dictRomId2SavInfo[RomID] = null;
}
return dictRomId2SavInfo[RomID];
}
/// <summary>
/// 发送请求即时存档列表
/// </summary>
/// <param name="RomID"></param>
public void SendGetGameSavList(int RomID)
{
Protobuf_Mine_GetGameSavList req = new Protobuf_Mine_GetGameSavList()
{
RomID = RomID,
};
App.log.Info($"SendGetGameSavList");
App.network.SendToServer((int)CommandID.CmdGamesavGetGameSavList, ProtoBufHelper.Serizlize(req));
}
void RecvGetGameSavList(byte[] reqData)
{
Protobuf_Mine_GetGameSavList_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Mine_GetGameSavList_RESP>(reqData);
Protobuf_Mine_GameSavInfo[] savArr = GetRomSaveIDList(msg.RomID);
for (int i = 0; i < savArr.Length; i++)
{
Protobuf_Mine_GameSavInfo info = msg.SavDataList.FirstOrDefault(w => w.SavDataIdx == i);
savArr[i] = info;
}
Eventer.Instance.PostEvent(EEvent.OnNetGameSavListUpdate, msg.RomID);
}
/// <summary>
/// 发送删除即时存档
/// </summary>
/// <param name="RomID"></param>
/// <param name="SavDataIdx"></param>
public void SendDelGameSavList(int RomID,int SavDataIdx)
{
Protobuf_Mine_DelGameSav req = new Protobuf_Mine_DelGameSav()
{
RomID = RomID,
SavDataIdx = SavDataIdx
};
App.log.Info($"SendDelGameSavList");
App.network.SendToServer((int)CommandID.CmdGamesavGetGameSavList, ProtoBufHelper.Serizlize(req));
}
void RecvDelGameSavList(byte[] reqData)
{
Protobuf_Mine_DelGameSav_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Mine_DelGameSav_RESP>(reqData);
Protobuf_Mine_GameSavInfo[] savArr = GetRomSaveIDList(msg.RomID);
savArr[msg.SavDataIdx] = null;
Eventer.Instance.PostEvent(EEvent.OnNetGameSavListUpdate, msg.RomID);
}
/// <summary>
/// 上传即时存档
/// </summary>
/// <param name="RomID"></param>
/// <param name="SavDataIdx"></param>
public void SendUpLoadGameSav(int RomID,int SavDataIdx, byte[] RawData, byte[] SavImgData)
{
//压缩
byte[] compressRawData = Helper.CompressByteArray(RawData);
//压缩
byte[] compressImgData = Helper.CompressByteArray(SavImgData);
Protobuf_Mine_UpLoadGameSav req = new Protobuf_Mine_UpLoadGameSav()
{
RomID = RomID,
SavDataIdx = SavDataIdx,
StateRaw = Google.Protobuf.ByteString.CopyFrom(compressRawData),
SavImg = Google.Protobuf.ByteString.CopyFrom(compressImgData),
};
App.log.Info($"SendDelGameSavList");
App.log.Info($"上传即时存档数据 原数据大小:{RawData.Length},压缩后;{compressRawData.Length}");
App.log.Info($"上传截图 原数据大小:{SavImgData.Length},压缩后;{compressImgData.Length}");
App.network.SendToServer((int)CommandID.CmdGamesavGetGameSavList, ProtoBufHelper.Serizlize(req));
}
void RecvUpLoadGameSav(byte[] reqData)
{
Protobuf_Mine_UpLoadGameSav_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Mine_UpLoadGameSav_RESP>(reqData);
Protobuf_Mine_GameSavInfo[] savArr = GetRomSaveIDList(msg.RomID);
savArr[msg.UploadSevInfo.SavDataIdx] = msg.UploadSevInfo;
Eventer.Instance.PostEvent(EEvent.OnNetGameSavListUpdate, msg.RomID);
}
/// <summary>
/// 即时存档或网络截图下载完成之后,需要先解压再使用
/// </summary>
/// <returns></returns>
public byte[] UnGzipData(byte[] data)
{
return Helper.DecompressByteArray(data);
}
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: c83a305f1221ec543930b06c37d80328

View File

@ -491,12 +491,20 @@ namespace AxibugEmuOnline.Client.Manager
App.log.Info($"鸡翅孙当上报成功");
}
/// <summary>
/// 即时存档加载完毕
/// </summary>
public void SendRoomPlayerReady()
/// <summary>
/// 即时存档加载完毕
/// </summary>
/// <param name="PushFrameNeedTimeUs">push帧所需平均时间微秒</param>
/// <param name="LoadStateNeedTimeUs">加载即时存档所需平均时间(微秒)</param>
/// <param name="VideoFrameShowNeedTimeUs">视频一帧所需时间(微秒)</param>
/// <param name="AudioFramePlayNeedTimeUs">音频处理一帧所需时间(微秒)</param>
public void SendRoomPlayerReady(float PushFrameNeedTimeUs,float LoadStateNeedTimeUs,float VideoFrameShowNeedTimeUs,float AudioFramePlayNeedTimeUs)
{
App.log.Debug("上报准备完毕");
_Protobuf_Room_Player_Ready.PushFrameNeedTimeUs = PushFrameNeedTimeUs;
_Protobuf_Room_Player_Ready.LoadStateNeedTimeUs = LoadStateNeedTimeUs;
_Protobuf_Room_Player_Ready.VideoFrameShowNeedTimeUs = VideoFrameShowNeedTimeUs;
_Protobuf_Room_Player_Ready.AudioFramePlayNeedTimeUs = AudioFramePlayNeedTimeUs;
App.network.SendToServer((int)CommandID.CmdRoomPlayerReady, ProtoBufHelper.Serizlize(_Protobuf_Room_Player_Ready));
}

View File

@ -25,7 +25,7 @@ namespace AxibugEmuOnline.Client.Manager
Motion = Motion,
RomID = RomID,
};
App.log.Info($"LeavnRoom");
App.log.Info($"SendGameStar");
App.network.SendToServer((int)CommandID.CmdGameMark, ProtoBufHelper.Serizlize(req));
}
@ -36,7 +36,7 @@ namespace AxibugEmuOnline.Client.Manager
void RecvGameStar(byte[] reqData)
{
Protobuf_Game_Mark_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_Game_Mark_RESP>(reqData);
Eventer.Instance.PostEvent(EEvent.OnDoStars, msg.RomID);
Eventer.Instance.PostEvent(EEvent.OnRomStarStateChanged, msg.RomID,msg.IsStar == 1);
}
}

View File

@ -35,7 +35,8 @@ namespace AxibugEmuOnline.Client
PauseCore();
Debug.Log($"快照加载:{Helper.FileMD5Hash(App.roomMgr.RawData)}");
m_inGameUI.Core.LoadStateFromBytes(App.roomMgr.RawData);
App.roomMgr.SendRoomPlayerReady();
//TODO ready时上报性能指标
App.roomMgr.SendRoomPlayerReady(0,0,0,0);
break;
case 2:
m_step = -1;

View File

@ -21,6 +21,7 @@ namespace AxibugEmuOnline.Server.Common
public string ClientVersion { get; set; }
public string AesKey { get; set; }
public string AesIv { get; set; }
public string savDataPath { get; set; }
}

View File

@ -0,0 +1,6 @@
namespace AxibugEmuOnline.Server.Common
{
internal class GameScreenConvet
{
}
}

View File

@ -16,6 +16,7 @@ namespace AxibugEmuOnline.Server.Manager
public void RecvGameMark(Socket _socket, byte[] reqData)
{
AppSrv.g_Log.DebugCmd("RecvGameMark");
Protobuf_Game_Mark msg = ProtoBufHelper.DeSerizlize<Protobuf_Game_Mark>(reqData);
ClientInfo _c = AppSrv.g_ClientMgr.GetClientForSocket(_socket);
Protobuf_Game_Mark_RESP respData = new Protobuf_Game_Mark_RESP();
@ -34,7 +35,8 @@ namespace AxibugEmuOnline.Server.Manager
{
while (reader.Read())
{
reader.GetInt32(0);
bHad = true;
break;
}
}
}
@ -134,7 +136,7 @@ namespace AxibugEmuOnline.Server.Manager
MySqlConnection conn = SQLPool.DequeueSQLConn("CheckIsRomStart");
try
{
string query = $"SELECT count(0) from rom_stars where uid = ?uid and = ?romid";
string query = $"SELECT count(id) from rom_stars where uid = ?uid and = ?romid";
using (var command = new MySqlCommand(query, conn))
{
// 设置参数值
@ -152,7 +154,7 @@ namespace AxibugEmuOnline.Server.Manager
}
catch (Exception e)
{
AppSrv.g_Log.Error(e);
AppSrv.g_Log.Error("CheckIsRomStar"+e);
}
SQLPool.EnqueueSQLConn(conn);
return bhad;

View File

@ -3,10 +3,6 @@ using AxibugEmuOnline.Server.Event;
using AxibugEmuOnline.Server.NetWork;
using AxibugProtobuf;
using MySql.Data.MySqlClient;
using Mysqlx;
using Org.BouncyCastle.Asn1.X9;
using Org.BouncyCastle.Ocsp;
using System.Collections;
using System.Net.Sockets;
namespace AxibugEmuOnline.Server.Manager

View File

@ -0,0 +1,154 @@
using AxibugEmuOnline.Server.Common;
using AxibugEmuOnline.Server.NetWork;
using AxibugProtobuf;
using MySql.Data.MySqlClient;
using System.Net.Sockets;
namespace AxibugEmuOnline.Server.Manager
{
public class SavDataManager
{
public SavDataManager()
{
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdGamesavGetGameSavList, RecvGetGameSavList);
}
public void RecvGetGameSavList(Socket _socket, byte[] reqData)
{
AppSrv.g_Log.DebugCmd("RecvGetGameSavList");
Protobuf_Mine_GetGameSavList msg = ProtoBufHelper.DeSerizlize<Protobuf_Mine_GetGameSavList>(reqData);
ClientInfo _c = AppSrv.g_ClientMgr.GetClientForSocket(_socket);
Protobuf_Mine_GetGameSavList_RESP respData = new Protobuf_Mine_GetGameSavList_RESP();
respData.RomID = msg.RomID;
Protobuf_Mine_GameSavInfo nulldata = null;
respData.SavDataList.Add(nulldata);
respData.SavDataList.Add(nulldata);
respData.SavDataList.Add(nulldata);
respData.SavDataList.Add(nulldata);
MySqlConnection conn = SQLPool.DequeueSQLConn("RecvGameMark");
try
{
string query = "SELECT `romid`, `savidx`, `savName`,`savNote`, `savUrl`,`savImgUrl`, `savDate` from user_gamesavedata where uid = ?uid and romid = ?romid";
bool bHad = false;
using (var command = new MySqlCommand(query, conn))
{
// 设置参数值
command.Parameters.AddWithValue("?uid", _c.UID);
command.Parameters.AddWithValue("?romid", msg.RomID);
using (var reader = command.ExecuteReader())
{
while (reader.Read())
{
Protobuf_Mine_GameSavInfo resp = new Protobuf_Mine_GameSavInfo()
{
BHadSaveData = true,
RomID = reader.GetInt32(0),
SavDataIdx = reader.GetInt32(1),
SavName = reader.GetString(2),
Note = reader.GetString(3),
SavUrl = reader.GetString(4),
SavImgUrl = reader.GetString(5),
SavDate = reader.GetDateTime(6).ToString()
};
respData.SavDataList[resp.SavDataIdx] = resp;
}
}
}
}
catch (Exception e)
{
}
SQLPool.EnqueueSQLConn(conn);
respData.RomID = msg.RomID;
AppSrv.g_ClientMgr.ClientSend(_c, (int)CommandID.CmdGamesavGetGameSavList, (int)ErrorCode.ErrorOk, ProtoBufHelper.Serizlize(respData));
}
public void RecvDelGameSav(Socket _socket, byte[] reqData)
{
Protobuf_Mine_DelGameSav msg = ProtoBufHelper.DeSerizlize<Protobuf_Mine_DelGameSav>(reqData);
ClientInfo _c = AppSrv.g_ClientMgr.GetClientForSocket(_socket);
Protobuf_Mine_DelGameSav_RESP respData = new Protobuf_Mine_DelGameSav_RESP();
ErrorCode errCode = ErrorCode.ErrorOk;
respData.RomID = msg.RomID;
bool bHad = false; string SavUrl = null; string SavImgUrl = null;
MySqlConnection conn = SQLPool.DequeueSQLConn("RecvGameMark");
try
{
string query = "SELECT `savUrl`,`savImgUrl`, `savDate` from user_gamesavedata where uid = ?uid and romid = ?romid and savidx = ?savidx";
using (var command = new MySqlCommand(query, conn))
{
// 设置参数值
command.Parameters.AddWithValue("?uid", _c.UID);
command.Parameters.AddWithValue("?romid", msg.RomID);
using (var reader = command.ExecuteReader())
{
while (reader.Read())
{
bHad = true;
SavUrl = reader.GetString(0);
SavImgUrl = reader.GetString(1);
}
}
}
}
catch (Exception e)
{
}
if (!bHad)
{
errCode = ErrorCode.ErrorRomDontHadSavedata;
}
else
{
bool bDelSav = FileDelete(Path.Combine(Config.cfg.savDataPath, SavUrl));
bool bDelImg = FileDelete(Path.Combine(Config.cfg.savDataPath, SavImgUrl));
if (bDelSav || !bDelImg)
{
errCode = ErrorCode.ErrorRomDontHadSavedata;
}
else
{
}
}
SQLPool.EnqueueSQLConn(conn);
respData.RomID = msg.RomID;
AppSrv.g_ClientMgr.ClientSend(_c, (int)CommandID.CmdGamesavGetGameSavList, (int)ErrorCode.ErrorOk, ProtoBufHelper.Serizlize(respData));
}
public bool FileDelete(string path)
{
if (!File.Exists(path))
return false;
try
{
File.Delete(path);
return true;
}
catch (Exception e)
{
return false;
}
}
public bool FileDelete(string path, byte[] data)
{
try
{
File.WriteAllBytes(path, data);
return true;
}
catch (Exception e)
{
return false;
}
}
}
}

View File

@ -82,6 +82,11 @@ namespace AxibugEmuOnline.Server
AESHelper.GenAesKeyIV();
}
break;
case "t1":
{
AppSrv.g_GameShareMgr.RecvGameMark(null, null);
}
break;
default:
Console.WriteLine("未知命令" + CommandStr);
break;

View File

@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<History>True|2025-01-07T05:54:02.0272718Z||;True|2025-01-07T10:47:36.6196477+08:00||;True|2025-01-07T01:21:34.5863249+08:00||;False|2025-01-07T01:20:39.5344134+08:00||;True|2025-01-07T00:21:47.4863058+08:00||;True|2025-01-07T00:16:42.7998249+08:00||;False|2025-01-07T00:16:02.8107509+08:00||;False|2025-01-02T15:36:18.1906464+08:00||;False|2025-01-02T15:36:06.5622643+08:00||;True|2024-12-27T18:24:49.7554320+08:00||;</History>
<History>True|2025-01-08T15:13:47.7309044Z||;True|2025-01-08T13:32:52.0590130+08:00||;True|2025-01-08T13:31:56.8589678+08:00||;True|2025-01-07T13:54:02.0272718+08:00||;True|2025-01-07T10:47:36.6196477+08:00||;True|2025-01-07T01:21:34.5863249+08:00||;False|2025-01-07T01:20:39.5344134+08:00||;True|2025-01-07T00:21:47.4863058+08:00||;True|2025-01-07T00:16:42.7998249+08:00||;False|2025-01-07T00:16:02.8107509+08:00||;False|2025-01-02T15:36:18.1906464+08:00||;False|2025-01-02T15:36:06.5622643+08:00||;True|2024-12-27T18:24:49.7554320+08:00||;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<Project>
<PropertyGroup>
<_PublishTargetUrl>G:\Sin365\AxibugEmuOnline\AxibugEmuOnline.Web\bin\Release\net8.0\publish\</_PublishTargetUrl>
<History>True|2025-01-07T02:37:18.6461694Z||;True|2024-09-12T14:18:38.6992653+08:00||;True|2024-09-12T14:08:58.4526827+08:00||;True|2024-08-22T14:13:06.3067002+08:00||;True|2024-08-14T10:33:10.9180984+08:00||;True|2024-08-13T18:28:27.5050523+08:00||;True|2024-08-13T18:25:47.6591234+08:00||;True|2024-08-13T18:25:17.5344107+08:00||;True|2024-08-13T17:46:23.4523329+08:00||;</History>
<History>True|2025-01-08T05:35:26.6793825Z||;True|2025-01-07T10:37:18.6461694+08:00||;True|2024-09-12T14:18:38.6992653+08:00||;True|2024-09-12T14:08:58.4526827+08:00||;True|2024-08-22T14:13:06.3067002+08:00||;True|2024-08-14T10:33:10.9180984+08:00||;True|2024-08-13T18:28:27.5050523+08:00||;True|2024-08-13T18:25:47.6591234+08:00||;True|2024-08-13T18:25:17.5344107+08:00||;True|2024-08-13T17:46:23.4523329+08:00||;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>

File diff suppressed because it is too large Load Diff

View File

@ -66,7 +66,12 @@ enum CommandID
//
CMD_Screen = 7001; // | 广 Protobuf_Screnn_Frame
CMD_GAME_MARK = 10101; // | Protobuf_Game_Mark | Protobuf_Game_Mark_RESP
//
CMD_GAMESAV_GetGameSavList = 8001;// | Protobuf_Mine_GetGameSavList | Protobuf_Mine_GetGameSavList_RESP
CMD_GAMESAV_DelGameSav = 8005;// | Protobuf_Mine_DelGameSavList | Protobuf_Mine_DelGameSavList_RESP
CMD_GAMESAV_UploadGameSav = 8010;// | Protobuf_Mine_UpLoadGameSavList | Protobuf_Mine_UpLoadGameSavList_RESP
CMD_GAME_MARK = 10101; // | Protobuf_Game_Mark | Protobuf_Game_Mark_RESP
}
enum ErrorCode
@ -79,8 +84,11 @@ enum ErrorCode
ERROR_ROOM_CANT_DO_CURR_STATE =50;//
ERROR_ROM_DONT_HAD_SAVEDATA = 80;//
ERROR_ROM_ALREADY_HAD_STAR =403;//
ERROR_ROM_DONT_HAD_STAR =404;//
}
enum LoginType
@ -441,4 +449,55 @@ message Protobuf_Game_Mark_RESP
int32 RomID = 1;//RomID
int32 IsStar = 2;// [0][1]
int32 stars = 3;//
}
message Protobuf_Mine_GetGameSavList
{
int32 RomID = 1;
}
message Protobuf_Mine_GetGameSavList_RESP
{
int32 RomID = 1;
repeated Protobuf_Mine_GameSavInfo SavDataList = 2;
}
message Protobuf_Mine_GameSavInfo
{
bool bHadSaveData = 1;//
int32 SavDataIdx = 2;//(0)
int32 RomID = 3;
RomPlatformType GamePlatformType = 4;
string SavDate = 5;//
string SavName = 6;
string Note = 7;//
string SavImgUrl = 8;//Url
string SavUrl = 9;//Url
}
message Protobuf_Mine_DelGameSav
{
int32 RomID = 1;//RomID
int32 SavDataIdx = 2;//(0)
}
message Protobuf_Mine_DelGameSav_RESP
{
int32 RomID = 1;//RomID
int32 SavDataIdx = 2;//
}
message Protobuf_Mine_UpLoadGameSav
{
int32 RomID = 1;//RomID
int32 SavDataIdx = 2;//(0)
bytes SavImg = 3;//
bytes StateRaw = 4;//byte数据
}
message Protobuf_Mine_UpLoadGameSav_RESP
{
int32 RomID = 1;//RomID
Protobuf_Mine_GameSavInfo UploadSevInfo = 2;//
}