protected virtual void HandleClientCmd(FSPPlayer player, FSPMessage msg) { uint playerId = player.id; //处理鉴权 if (!player.HasAuthed) { if (msg.cmd == FSPBasicCmd.AUTH) { player.SetAuth(msg.args[0]); } else { Debuger.LogWarning("当前Player未鉴权,无法处理该Cmd:{0}", msg.cmd); } return; } switch (msg.cmd) { case FSPBasicCmd.GAME_BEGIN: { Debuger.Log("GAME_BEGIN, playerId = {0}, cmd = {1}", playerId, msg); SetFlag(playerId, ref m_GameBeginFlag, "m_GameBeginFlag"); break; } case FSPBasicCmd.ROUND_BEGIN: { Debuger.Log("ROUND_BEGIN, playerId = {0}, cmd = {1}", playerId, msg); SetFlag(playerId, ref m_RoundBeginFlag, "m_RoundBeginFlag"); break; } case FSPBasicCmd.CONTROL_START: { Debuger.Log("CONTROL_START, playerId = {0}, cmd = {1}", playerId, msg); SetFlag(playerId, ref m_ControlStartFlag, "m_ControlStartFlag"); break; } case FSPBasicCmd.ROUND_END: { Debuger.Log("ROUND_END, playerId = {0}, cmd = {1}", playerId, msg); SetFlag(playerId, ref m_RoundEndFlag, "m_RoundEndFlag"); break; } case FSPBasicCmd.GAME_END: { Debuger.Log("GAME_END, playerId = {0}, cmd = {1}", playerId, msg); SetFlag(playerId, ref m_GameEndFlag, "m_GameEndFlag"); break; } case FSPBasicCmd.GAME_EXIT: { Debuger.Log("GAME_EXIT, playerId = {0}, cmd = {1}", playerId, msg); HandleGameExit(playerId, msg); break; } default: { Debuger.Log("playerId = {0}, cmd = {1}", playerId, msg); AddCmdToCurrentFrame(playerId, msg); break; } } }
//--------------------------------------------------------- /// <summary> /// 处理来自客户端的 Cmd /// 对其中的关键VKey进行处理 /// 并且收集业务VKey /// </summary> /// <param name="player"></param> /// <param name="cmd"></param> protected virtual void HandleClientCmd(FSPPlayer player, FSPVKey cmd) { uint playerId = player.Id; //处理鉴权 if (!player.HasAuth) { Debuger.Log(LOG_TAG, "HandleClientCmd() hasAuth = false! Wait AUTH!"); if (cmd.vkey == FSPVKeyBase.AUTH) { Debuger.Log(LOG_TAG, "HandleClientCmd() AUTH, playerId={0}", playerId); player.SetAuth(cmd.args[0]); } return; } switch (cmd.vkey) { case FSPVKeyBase.GAME_BEGIN: { Debuger.Log(LOG_TAG, "HandleClientCmd() GAME_BEGIN, playerId = {0}, cmd = {1}", playerId, cmd); SetFlag(playerId, ref m_GameBeginFlag, "m_GameBeginFlag"); break; } case FSPVKeyBase.ROUND_BEGIN: { Debuger.Log(LOG_TAG, "HandleClientCmd() ROUND_BEGIN, playerId = {0}, cmd = {1}", playerId, cmd); SetFlag(playerId, ref m_RoundBeginFlag, "m_RoundBeginFlag"); break; } case FSPVKeyBase.CONTROL_START: { Debuger.Log(LOG_TAG, "HandleClientCmd() CONTROL_START, playerId = {0}, cmd = {1}", playerId, cmd); SetFlag(playerId, ref m_ControlStartFlag, "m_ControlStartFlag"); break; } case FSPVKeyBase.ROUND_END: { Debuger.Log(LOG_TAG, "HandleClientCmd() ROUND_END, playerId = {0}, cmd = {1}", playerId, cmd); SetFlag(playerId, ref m_RoundEndFlag, "m_RoundEndFlag"); break; } case FSPVKeyBase.GAME_END: { Debuger.Log(LOG_TAG, "HandleClientCmd() GAME_END, playerId = {0}, cmd = {1}", playerId, cmd); SetFlag(playerId, ref m_GameEndFlag, "m_GameEndFlag"); break; } case FSPVKeyBase.GAME_EXIT: { Debuger.Log(LOG_TAG, "HandleClientCmd() GAME_EXIT, playerId = {0}, cmd = {1}", playerId, cmd); HandleGameExit(playerId, cmd); break; } default: { Debuger.Log(LOG_TAG, "HandleClientCmd() playerId = {0}, cmd = {1}", playerId, cmd); AddCmdToCurrentFrame(playerId, cmd); break; } } }