服务器逻辑帧驱动实现,房间protobuf定义

This commit is contained in:
sin365 2024-08-21 11:04:53 +08:00
parent c30df0b284
commit a13669dc57
11 changed files with 3500 additions and 247 deletions

View File

@ -9,10 +9,10 @@
<ItemGroup> <ItemGroup>
<Reference Include="Google.Protobuf"> <Reference Include="Google.Protobuf">
<HintPath>..\..\Lib\Google.Protobuf.dll</HintPath> <HintPath>..\Lib\Google.Protobuf.dll</HintPath>
</Reference> </Reference>
<Reference Include="HaoYueNet.ServerNetwork"> <Reference Include="HaoYueNet.ServerNetwork">
<HintPath>..\..\Lib\HaoYueNet.ServerNetwork.dll</HintPath> <HintPath>..\Lib\HaoYueNet.ServerNetwork.dll</HintPath>
</Reference> </Reference>
</ItemGroup> </ItemGroup>

View File

@ -7,6 +7,7 @@ namespace AxibugEmuOnline.Server
public static class AppSrv public static class AppSrv
{ {
public static TickManager g_Tick;
public static ClientManager g_ClientMgr; public static ClientManager g_ClientMgr;
public static LogManager g_Log; public static LogManager g_Log;
public static LoginManager g_Login; public static LoginManager g_Login;
@ -17,6 +18,7 @@ namespace AxibugEmuOnline.Server
public static void InitServer(int port) public static void InitServer(int port)
{ {
g_Tick = new TickManager();
g_ClientMgr = new ClientManager(); g_ClientMgr = new ClientManager();
g_ClientMgr.Init(45000, 120); g_ClientMgr.Init(45000, 120);
g_Log = new LogManager(); g_Log = new LogManager();

View File

@ -1,4 +1,6 @@
using AxibugProtobuf; using AxibugEmuOnline.Server.Common;
using AxibugEmuOnline.Server.NetWork;
using AxibugProtobuf;
using System.Net.Sockets; using System.Net.Sockets;
using System.Timers; using System.Timers;
@ -12,8 +14,34 @@ namespace AxibugEmuOnline.Server.Manager
public Socket _socket { get; set; } public Socket _socket { get; set; }
public bool IsOffline { get; set; } = false; public bool IsOffline { get; set; } = false;
public DateTime LogOutDT { get; set; } public DateTime LogOutDT { get; set; }
public DateTime LogInDT { get; set; }
public UserRoomState RoomState { get; set; } = new UserRoomState();
public TimeSpan LastStartPingTime { get; set; }
public int LastPingSeed { get; set; }
public double NetDelay { get; set; }
}
public class UserRoomState
{
public int RoomID { get; private set; }
public int PlayerIdx { get; private set; }
public UserRoomState()
{
ClearRoomData();
}
public void SetRoomData(int roomID,int playerIdx)
{
RoomID = roomID;
PlayerIdx = playerIdx;
}
public void ClearRoomData()
{
RoomID = -1;
PlayerIdx = -1;
}
} }
public class ClientManager public class ClientManager
@ -23,8 +51,10 @@ namespace AxibugEmuOnline.Server.Manager
private Dictionary<long?, ClientInfo> _DictUIDClient = new Dictionary<long?, ClientInfo>(); private Dictionary<long?, ClientInfo> _DictUIDClient = new Dictionary<long?, ClientInfo>();
private long TestUIDSeed = 0; private long TestUIDSeed = 0;
private System.Timers.Timer _ClientCheckTimer; private System.Timers.Timer clientCheckTimer;
private AutoResetEvent pingTickARE;
private long _RemoveOfflineCacheMin; private long _RemoveOfflineCacheMin;
private Thread threadPingTick;
/// <summary> /// <summary>
/// 初始化并指定检查时间 /// 初始化并指定检查时间
/// </summary> /// </summary>
@ -32,13 +62,22 @@ namespace AxibugEmuOnline.Server.Manager
/// <param name="RemoveOfflineCache">清理掉线分钟数</param> /// <param name="RemoveOfflineCache">清理掉线分钟数</param>
public void Init(long ticktime, long RemoveOfflineCacheMin) public void Init(long ticktime, long RemoveOfflineCacheMin)
{ {
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdPing, OnCmdPing);
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdPong, OnCmdPong);
pingTickARE = AppSrv.g_Tick.AddNewARE(TickManager.TickType.Interval_2000MS);
//换算成毫秒 //换算成毫秒
_RemoveOfflineCacheMin = RemoveOfflineCacheMin; _RemoveOfflineCacheMin = RemoveOfflineCacheMin;
_ClientCheckTimer = new System.Timers.Timer(); clientCheckTimer = new System.Timers.Timer();
_ClientCheckTimer.Interval = ticktime; clientCheckTimer.Interval = ticktime;
_ClientCheckTimer.AutoReset = true; clientCheckTimer.AutoReset = true;
_ClientCheckTimer.Elapsed += new ElapsedEventHandler(ClientCheckClearOffline_Elapsed); clientCheckTimer.Elapsed += new ElapsedEventHandler(ClientCheckClearOffline_Elapsed);
_ClientCheckTimer.Enabled = true; clientCheckTimer.Enabled = true;
pingTickARE = AppSrv.g_Tick.AddNewARE(TickManager.TickType.Interval_2000MS);
threadPingTick = new Thread(PingAllLoop);
threadPingTick.Start();
} }
public long GetNextUID() public long GetNextUID()
@ -192,11 +231,75 @@ namespace AxibugEmuOnline.Server.Manager
#endregion #endregion
#region Ping
void PingAllLoop()
{
while (true)
{
pingTickARE.WaitOne();
AppSrv.g_Log.Info("PingAll");
PingAll();
}
}
void PingAll()
{
List<ClientInfo> clientlist = GetOnlineClientList();
int randSeed = new Random().Next(0, int.MaxValue);
foreach (var _c in clientlist)
{
_c.LastPingSeed = randSeed;
_c.LastStartPingTime = AppSrv.g_Tick.sw.Elapsed;
Protobuf_Ping resp = new Protobuf_Ping()
{
Seed = randSeed,
};
AppSrv.g_ClientMgr.ClientSend(_c._socket, (int)CommandID.CmdPing, (int)ErrorCode.ErrorOk, ProtoBufHelper.Serizlize(resp));
}
}
public void OnCmdPing(Socket sk, byte[] reqData)
{
AppSrv.g_Log.Debug($"OnCmdPing");
ClientInfo _c = AppSrv.g_ClientMgr.GetClientForSocket(sk);
Protobuf_Ping msg = ProtoBufHelper.DeSerizlize<Protobuf_Ping>(reqData);
//创建成功下行
Protobuf_Pong resp = new Protobuf_Pong()
{
Seed = msg.Seed,
};
AppSrv.g_ClientMgr.ClientSend(_c._socket, (int)CommandID.CmdPong, (int)ErrorCode.ErrorOk, ProtoBufHelper.Serizlize(resp));
}
public void OnCmdPong(Socket sk, byte[] reqData)
{
AppSrv.g_Log.Debug($"OnCmdPong");
ClientInfo _c = AppSrv.g_ClientMgr.GetClientForSocket(sk);
Protobuf_Pong msg = ProtoBufHelper.DeSerizlize<Protobuf_Pong>(reqData);
if (_c.LastPingSeed == msg.Seed)
{
TimeSpan current = AppSrv.g_Tick.sw.Elapsed;
TimeSpan delta = current - _c.LastStartPingTime;
_c.NetDelay = delta.TotalSeconds;
}
}
#endregion
public void ClientSendALL(int CMDID, int ERRCODE, byte[] data, long SkipUID = -1) public void ClientSendALL(int CMDID, int ERRCODE, byte[] data, long SkipUID = -1)
{ {
ClientSend(ClientList, CMDID, ERRCODE, data, SkipUID); ClientSend(ClientList, CMDID, ERRCODE, data, SkipUID);
} }
public void ClientSend(List<long> UIDs,int CMDID, int ERRCODE, byte[] data, long SkipUID = -1)
{
for (int i = 0; i < UIDs.Count(); i++)
{
if (!GetClientByUID(UIDs[i], out ClientInfo _c, true))
continue;
AppSrv.g_SocketMgr.SendToSocket(_c._socket, CMDID, ERRCODE, data);
}
}
/// <summary> /// <summary>
/// 给一组用户发送数据 /// 给一组用户发送数据
/// </summary> /// </summary>

View File

@ -2,7 +2,6 @@
using AxibugEmuOnline.Server.Manager; using AxibugEmuOnline.Server.Manager;
using AxibugEmuOnline.Server.NetWork; using AxibugEmuOnline.Server.NetWork;
using AxibugProtobuf; using AxibugProtobuf;
using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
namespace AxibugEmuOnline.Server namespace AxibugEmuOnline.Server

View File

@ -26,7 +26,6 @@ namespace AxibugEmuOnline.Server.Manager
Token = "", Token = "",
UID = cinfo.UID UID = cinfo.UID
}); });
} }
} }
} }

View File

@ -2,9 +2,10 @@
using AxibugEmuOnline.Server.Manager; using AxibugEmuOnline.Server.Manager;
using AxibugEmuOnline.Server.NetWork; using AxibugEmuOnline.Server.NetWork;
using AxibugProtobuf; using AxibugProtobuf;
using System.Net; using System;
using System.Net.Sockets; using System.Net.Sockets;
using static System.Runtime.InteropServices.JavaScript.JSType; using System.Runtime.InteropServices;
using System.Xml;
namespace AxibugEmuOnline.Server namespace AxibugEmuOnline.Server
{ {
@ -12,14 +13,22 @@ namespace AxibugEmuOnline.Server
public class RoomManager public class RoomManager
{ {
Dictionary<int, Data_RoomData> mDictRoom = new Dictionary<int, Data_RoomData>(); Dictionary<int, Data_RoomData> mDictRoom = new Dictionary<int, Data_RoomData>();
List<int> mKeyRoomList = new List<int>();
AutoResetEvent roomTickARE;
Thread threadRoomTick;
int RoomIDSeed = 1; int RoomIDSeed = 1;
public RoomManager() public RoomManager()
{ {
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdRoomList, OnCmdRoomList); NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdRoomList, OnCmdRoomList);
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdRoomCreate, OnCmdRoomCreate); NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdRoomCreate, OnCmdRoomCreate);
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdRoomJoin, OnCmdRoomJoin); NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdRoomJoin, OnCmdRoomJoin);
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdRoomLeave, OnCmdRoomLeave); NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdRoomLeave, OnCmdRoomLeave);
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdRoomSingelPlayerInput, OnSingelPlayerInput);
roomTickARE = AppSrv.g_Tick.AddNewARE(TickManager.TickType.Interval_16MS);
threadRoomTick = new Thread(UpdateLoopTick);
threadRoomTick.Start();
} }
#region #region
@ -36,6 +45,7 @@ namespace AxibugEmuOnline.Server
if (!mDictRoom.ContainsKey(data.RoomID)) if (!mDictRoom.ContainsKey(data.RoomID))
{ {
mDictRoom.Add(data.RoomID, data); mDictRoom.Add(data.RoomID, data);
mKeyRoomList.Remove(data.RoomID);
} }
} }
} }
@ -47,16 +57,16 @@ namespace AxibugEmuOnline.Server
if (mDictRoom.ContainsKey(RoomID)) if (mDictRoom.ContainsKey(RoomID))
{ {
mDictRoom.Remove(RoomID); mDictRoom.Remove(RoomID);
mKeyRoomList.Remove(RoomID);
} }
} }
} }
public Data_RoomData GetRoomData(int RoomID) public Data_RoomData GetRoomData(int RoomID)
{ {
if (!mDictRoom.ContainsKey(RoomID)) if (!mDictRoom.TryGetValue(RoomID,out Data_RoomData data))
return null; return null;
return data;
return mDictRoom[RoomID];
} }
List<Data_RoomData> GetRoomList() List<Data_RoomData> GetRoomList()
@ -203,6 +213,16 @@ namespace AxibugEmuOnline.Server
AppSrv.g_ClientMgr.ClientSend(_c, (int)CommandID.CmdRoomLeave, (int)ErrorCode.ErrorOk, ProtoBufHelper.Serizlize(resp)); AppSrv.g_ClientMgr.ClientSend(_c, (int)CommandID.CmdRoomLeave, (int)ErrorCode.ErrorOk, ProtoBufHelper.Serizlize(resp));
Protobuf_Room_MyRoom_State_Change(msg.RoomID); Protobuf_Room_MyRoom_State_Change(msg.RoomID);
} }
public void OnSingelPlayerInput(Socket sk, byte[] reqData)
{
ClientInfo _c = AppSrv.g_ClientMgr.GetClientForSocket(sk);
Protobuf_Room_SinglePlayerInputData msg = ProtoBufHelper.DeSerizlize<Protobuf_Room_SinglePlayerInputData>(reqData);
Data_RoomData room = GetRoomData(_c.RoomState.RoomID);
if (room == null)
return;
room.SetPlayerInput(_c.RoomState.PlayerIdx, msg.FrameID, (ushort)msg.InputData);
}
/// <summary> /// <summary>
/// 广播房间状态变化 /// 广播房间状态变化
@ -252,7 +272,7 @@ namespace AxibugEmuOnline.Server
errcode = ErrorCode.ErrorRoomSlotReadlyHadPlayer; errcode = ErrorCode.ErrorRoomSlotReadlyHadPlayer;
return false; return false;
} }
room.Player1_UID = _c.UID; room.SetPlayerUID(0,_c);
} }
//其他玩家 //其他玩家
else else
@ -262,7 +282,7 @@ namespace AxibugEmuOnline.Server
errcode = ErrorCode.ErrorRoomSlotReadlyHadPlayer; errcode = ErrorCode.ErrorRoomSlotReadlyHadPlayer;
return false; return false;
} }
room.Player2_UID = _c.UID; room.SetPlayerUID(1, _c);
} }
//广播房间 //广播房间
@ -287,10 +307,7 @@ namespace AxibugEmuOnline.Server
return false; return false;
} }
if (room.Player1_UID == _c.UID) room.RemovePlayer(_c);
room.Player1_UID = -1;
if (room.Player2_UID == _c.UID)
room.Player2_UID = -1;
if (room.PlayerState == RoomPlayerState.NonePlayerState) if (room.PlayerState == RoomPlayerState.NonePlayerState)
{ {
@ -306,26 +323,108 @@ namespace AxibugEmuOnline.Server
return true; return true;
} }
#endregion #endregion
#region
void UpdateLoopTick()
{
while (true)
{
roomTickARE.WaitOne();
UpdateAllRoomLogic();
}
}
void UpdateAllRoomLogic()
{
for (int i = 0; i < mKeyRoomList.Count; i++)
{
int roomid = mKeyRoomList[i];
if (!mDictRoom.TryGetValue(roomid,out Data_RoomData room))
continue;
if (room.GameState > RoomGameState.InGame)
continue;
//更新帧
room.TakeFrame();
//广播
room.SynInputData();
}
}
#endregion
} }
public class Data_RoomData public class Data_RoomData
{ {
public int RoomID; public int RoomID { get; private set; }
public int GameRomID; public int GameRomID { get; private set; }
public string RomHash; public string RomHash { get; private set; }
public long Player1_UID; public bool bNeedLoadState { get; private set; }
public long Player2_UID; public int LoadStateFrame { get; private set; }
public Google.Protobuf.ByteString LoadStateRaw { get; set; }
public long Player1_UID { get; private set; }
public long Player2_UID { get; private set; }
public long Player3_UID { get; private set; }
public long Player4_UID { get; private set; }
public bool[] PlayerReadyState { get; private set; }
public List<long> SynUIDs;
public RoomPlayerState PlayerState => getPlayerState(); public RoomPlayerState PlayerState => getPlayerState();
public RoomGameState GameState; public RoomGameState GameState;
public uint mCurrFrameId = 0;
public ServerInputSnapShot mCurrInputData;
public Queue<(uint, ServerInputSnapShot)> mInputQueue;
//TODO
public Dictionary<int, Queue<byte[]>> mDictPlayerIdx2SendQueue;
public void Init(int roomID,int gameRomID,string roomHash) public void Init(int roomID, int gameRomID, string roomHash, bool bloadState = false)
{ {
RoomID = roomID; RoomID = roomID;
GameRomID = gameRomID; GameRomID = gameRomID;
RomHash = roomHash; RomHash = roomHash;
Player1_UID = -1; Player1_UID = -1;
Player2_UID = -1; Player2_UID = -1;
Player3_UID = -1;
Player4_UID = -1;
SynUIDs = new List<long>();//广播角色列表
GameState = RoomGameState.NoneGameState; GameState = RoomGameState.NoneGameState;
mCurrInputData = new ServerInputSnapShot();
mInputQueue = new Queue<(uint, ServerInputSnapShot)>();
}
public void SetPlayerUID(int PlayerIdx,ClientInfo _c)
{
long oldUID = -1;
switch (PlayerIdx)
{
case 0: oldUID = Player1_UID; Player1_UID = _c.UID; break;
case 1: oldUID = Player2_UID; Player2_UID = _c.UID; break;
case 2: oldUID = Player3_UID; Player3_UID = _c.UID; break;
case 3: oldUID = Player4_UID; Player4_UID = _c.UID; break;
}
if(oldUID <= 0)
SynUIDs.Remove(oldUID);
SynUIDs.Add(_c.UID);
_c.RoomState.SetRoomData(this.RoomID, PlayerIdx);
}
public void RemovePlayer(ClientInfo _c)
{
int PlayerIdx = GetPlayerIdx(_c);
switch (PlayerIdx)
{
case 0: Player1_UID = -1; SynUIDs.Remove(_c.UID);break;
case 1: Player2_UID = -1; SynUIDs.Remove(_c.UID);break;
case 2: Player3_UID = -1; SynUIDs.Remove(_c.UID);break;
case 3: Player4_UID = -1; SynUIDs.Remove(_c.UID);break;
}
_c.RoomState.ClearRoomData();
}
int GetPlayerIdx(ClientInfo _c)
{
if (Player1_UID == _c.UID) return 0;
if (Player2_UID == _c.UID) return 1;
if (Player3_UID == _c.UID) return 2;
if (Player4_UID == _c.UID) return 3;
return -1;
} }
RoomPlayerState getPlayerState() RoomPlayerState getPlayerState()
@ -366,5 +465,65 @@ namespace AxibugEmuOnline.Server
return list; return list;
} }
public void SetPlayerInput(int PlayerIdx,long mFrameID,ushort input)
{
switch (PlayerIdx)
{
case 0: mCurrInputData.p1 = input; break;
case 1: mCurrInputData.p2 = input; break;
case 2: mCurrInputData.p3 = input; break;
case 3: mCurrInputData.p4 = input; break;
}
}
public void ClearPlayerInput(int PlayerIdx)
{
switch (PlayerIdx)
{
case 0: mCurrInputData.p1 = 0; break;
case 1: mCurrInputData.p2 = 0; break;
case 2: mCurrInputData.p3 = 0; break;
case 3: mCurrInputData.p4 = 0; break;
}
}
public void TakeFrame()
{
mInputQueue.Enqueue((mCurrFrameId, mCurrInputData));
mCurrFrameId++;
}
/// <summary>
/// 广播数据
/// </summary>
public void SynInputData()
{
while (mInputQueue.Count > 0)
{
(uint frameId, ServerInputSnapShot inputdata) data = mInputQueue.Dequeue();
Protobuf_Room_Syn_RoomFrameAllInput resp = new Protobuf_Room_Syn_RoomFrameAllInput()
{
FrameID = data.frameId,
InputData = data.inputdata.all
};
AppSrv.g_ClientMgr.ClientSendALL((int)CommandID.CmdRoomSyn, (int)ErrorCode.ErrorOk, ProtoBufHelper.Serizlize(resp));
}
}
}
[StructLayout(LayoutKind.Explicit)]
public struct ServerInputSnapShot
{
[FieldOffset(0)]
public UInt64 all;
[FieldOffset(0)]
public ushort p1;
[FieldOffset(2)]
public ushort p2;
[FieldOffset(4)]
public ushort p3;
[FieldOffset(6)]
public ushort p4;
} }
} }

View File

@ -0,0 +1,72 @@
using System.Diagnostics;
namespace AxibugEmuOnline.Server.Manager
{
public class TickManager
{
public Stopwatch sw;
public enum TickType
{
Interval_16MS,
Interval_32MS,
Interval_2000MS,
}
System.Timers.Timer mTimer16ms;
System.Timers.Timer mTimer32ms;
System.Timers.Timer mTimer2000ms;
List<AutoResetEvent> mAREList16ms;
List<AutoResetEvent> mAREList32ms;
List<AutoResetEvent> mAREList2000ms;
public TickManager()
{
sw = Stopwatch.StartNew();
mAREList16ms = new List<AutoResetEvent>();
mAREList32ms = new List<AutoResetEvent>();
mAREList2000ms = new List<AutoResetEvent>();
mTimer16ms = new System.Timers.Timer(16);//实例化Timer类设置间隔时间为10000毫秒
mTimer16ms.Elapsed += new System.Timers.ElapsedEventHandler((source, e) => { UpdateARE(mAREList16ms); });//到达时间的时候执行事件;
mTimer16ms.AutoReset = true;//设置是执行一次false还是一直执行(true)
mTimer16ms.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件
mTimer16ms.Start();
mTimer32ms = new System.Timers.Timer(32);//实例化Timer类设置间隔时间为10000毫秒
mTimer32ms.Elapsed += new System.Timers.ElapsedEventHandler((source, e) => { UpdateARE(mAREList32ms); });//到达时间的时候执行事件;
mTimer32ms.AutoReset = true;//设置是执行一次false还是一直执行(true)
mTimer32ms.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件
mTimer32ms.Start();
mTimer2000ms = new System.Timers.Timer(2000);//实例化Timer类设置间隔时间为10000毫秒
mTimer2000ms.Elapsed += new System.Timers.ElapsedEventHandler((source, e) => { UpdateARE(mAREList2000ms); });//到达时间的时候执行事件;
mTimer2000ms.AutoReset = true;//设置是执行一次false还是一直执行(true)
mTimer2000ms.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件
mTimer2000ms.Start();
}
public AutoResetEvent AddNewARE(TickType tikeType)
{
AutoResetEvent are = new AutoResetEvent(false);
switch (tikeType)
{
case TickType.Interval_16MS:
mAREList16ms.Add(are);
break;
case TickType.Interval_32MS:
mAREList32ms.Add(are);
break;
case TickType.Interval_2000MS:
mAREList2000ms.Add(are);
break;
}
return are;
}
public void UpdateARE(List<AutoResetEvent> are)
{
for (int i = 0; i < are.Count; i++)
are[i].Set();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -12,5 +12,5 @@ for /f "delims=" %%i in ('dir /b proto "proto/*.proto"') do (
echo "==>>build finish" echo "==>>build finish"
echo "==>>copy cs" echo "==>>copy cs"
copy %cd%\out\CS\ ..\AxibugEmuOnline.Server\AxibugEmuOnline.Server\Protobuf copy %cd%\out\CS\ ..\AxibugEmuOnline.Server\Protobuf
pause pause

File diff suppressed because it is too large Load Diff

View File

@ -6,26 +6,54 @@ enum CommandID
{ {
CMD_DEFAUL = 0;//使 CMD_DEFAUL = 0;//使
//ping请求 ->->->->
CMD_PING = 1; //Ping | Protobuf_Ping
CMD_PONG = 2; //Pong | Protobuf_Pong
CMD_LOGIN = 2001; // | Protobuf_Login | Protobuf_Login_RESP CMD_LOGIN = 2001; // | Protobuf_Login | Protobuf_Login_RESP
CMD_CHATMSG = 4001; //广 | Protobuf_ChatMsg | Protobuf_ChatMsg_RESP CMD_CHATMSG = 4001; //广 | Protobuf_ChatMsg | Protobuf_ChatMsg_RESP
// //
CMD_Room_List = 5001; // | Protobuf_Room_List | Protobuf_Room_List_RESP CMD_Room_List = 5001; // | Protobuf_Room_List | Protobuf_Room_List_RESP
CMD_Room_List_Update = 5002; // Protobuf_Room_Update_RESP CMD_Room_List_Update = 5002; // Protobuf_Room_Update_RESP
// //
CMD_Room_Create = 5101; // Protobuf_Room_Create | Protobuf_Room_Create_RESP CMD_Room_Create = 5101; // Protobuf_Room_Create | Protobuf_Room_Create_RESP
CMD_Room_Join = 5105; // Protobuf_Room_Join | Protobuf_Room_Join_RESP
CMD_Room_Leave = 5106; // Protobuf_Room_Leave | Protobuf_Room_Leave_RESP
CMD_Room_MyRoom_State_Changed = 5110; // Protobuf_Room_MyRoom_State_Change
CMD_Room_Join = 5105; // Protobuf_Room_Join | Protobuf_Room_Join_RESP //5201 ~ 5204 ~ 5208
//
CMD_Room_Leave = 5106; // Protobuf_Room_Leave | Protobuf_Room_Leave_RESP //
//
CMD_Room_MyRoom_State_Changed = 5110; // Protobuf_Room_MyRoom_State_Change; //
//
// Step0广"等待-主机上报即使存档" CMD_Room_WaitStep WaitStep=[0] ---> )
// CMD_Room_HostPlayer_UpdateStateRaw消息
// Step1
//
// Step1广"等待-全员加载即时存档" CMD_Room_WaitStep WaitStep=[1] ---> )
// ROM和即时存档 CMD_Room_Player_Ready
// Ready之后FrameStep2
//
// Step2广"开始" CMD_Room_WaitStep WaitStep=[2] --->
//
//
// PS[] CMD_Room_HostPlayer_UpdateStateRaw
// Step1走流程
//
CMD_Room_WaitStep = 5201; //Step通知 Protobuf_Room_WaitStep_RESP
CMD_Room_HostPlayer_UpdateStateRaw = 5204; // Protobuf_Room_HostPlayer_UpdateStateRaw
CMD_Room_Player_Ready = 5208; // Protobuf_Room_Player_Ready
// //
CMD_Screen = 6001; // | 广 Protobuf_Screnn_Frame CMD_Room_Singel_PlayerInput = 6010; // Protobuf_Room_SinglePlayerInputData
CMD_ROOM_SYN = 6015; // Protobuf_Room_Syn_RoomFrameAllInput
//
CMD_Screen = 7001; // | 广 Protobuf_Screnn_Frame
} }
enum ErrorCode enum ErrorCode
@ -62,8 +90,12 @@ enum RoomPlayerState
enum RoomGameState enum RoomGameState
{ {
None_GameState = 0;// None_GameState = 0;//
InGame = 1;// OnlyHost = 1;//
Pause = 2;// ReadyStep_0 = 2;//ReadyStep0
ReadyStep_1 = 3;//ReadyStep1
ReadyStep_2 = 4;//ReadyStep2
Pause = 5;//
InGame = 6;//
} }
@ -88,6 +120,15 @@ message Protobuf_ChatMsg_RESP
int64 Date = 3;// int64 Date = 3;//
} }
message Protobuf_Ping
{
int32 Seed = 1;//
}
message Protobuf_Pong
{
int32 Seed = 1;//
}
// //
message Protobuf_Login message Protobuf_Login
@ -101,14 +142,14 @@ message Protobuf_Login
// //
message Protobuf_Login_RESP message Protobuf_Login_RESP
{ {
string Token = 1;// string DeviceUUID = 1;//
string LastLoginDate = 2;// string Token = 2;//
string RegDate = 3;// string LastLoginDate = 3;//
LoginResultStatus Status = 4;// [1][0] string RegDate = 4;//
int64 UID = 5; LoginResultStatus Status = 5;// [1][0]
int64 UID = 6;
} }
message Protobuf_Room_List message Protobuf_Room_List
{ {
@ -146,6 +187,18 @@ message Protobuf_Screnn_Frame
bytes RawBitmap = 3;// bytes RawBitmap = 3;//
} }
message Protobuf_Room_SinglePlayerInputData
{
uint32 FrameID = 1;//
uint32 InputData = 2;//
}
message Protobuf_Room_Syn_RoomFrameAllInput
{
uint32 FrameID = 1;//
uint64 InputData = 2;//
}
message Protobuf_Room_Create message Protobuf_Room_Create
{ {
int32 GameRomID = 1; int32 GameRomID = 1;
@ -182,3 +235,19 @@ message Protobuf_Room_MyRoom_State_Change
{ {
Protobuf_Room_MiniInfo RoomMiniInfo = 1;// Protobuf_Room_MiniInfo RoomMiniInfo = 1;//
} }
message Protobuf_Room_WaitStep_RESP
{
int32 WaitStep = 1;// [0] [1] [2]
}
message Protobuf_Room_HostPlayer_UpdateStateRaw
{
int32 ReadyFrame = 1;// (0
bytes LoadStateRaw = 2;//byte数据
}
message Protobuf_Room_Player_Ready
{
}