local FrameCmdStatistic_Model = {} local battle_common_pb = require 'Proto/battle_common_pb' local private = { cacheFrame2CmdInfo = {getFrame2CmdDic=nil,handleFrame2CmdDic=nil}, } function FrameCmdStatistic_Model.OnStartup() NetManager.RegisterMsgCB(MessageEnums.MessageG2CNeedUploadFrameStatistic, private.OnG2CNeedUploadFrameStatistic) end function FrameCmdStatistic_Model.SetCacheFrame2CmdInfo() private.cacheFrame2CmdInfo.getFrame2CmdDic, private.cacheFrame2CmdInfo.handleFrame2CmdDic = BattleDataGetter.GetFrame2CmdCountDicAndClear() private.cacheFrame2CmdInfo.maxFrame = BattleDataGetter.GetCurFrameIndex() private.timerHandle = TimerUtil.Interval(private.ClearCacheFrame2CmdInfo,30,1) -- 如果一致,则30秒后清理缓存 end function private.OnG2CNeedUploadFrameStatistic(msg) local gRoomId = msg.gRoomId local statistic = battle_common_pb.Frame2CmdStatistic() local frameCount = private.cacheFrame2CmdInfo.maxFrame or 0 local getFrame2CmdDic = private.cacheFrame2CmdInfo.getFrame2CmdDic local handleFrame2CmdDic = private.cacheFrame2CmdInfo.handleFrame2CmdDic for i = 1,frameCount do table.insert(statistic.getCmds, getFrame2CmdDic[i] or 0) table.insert(statistic.handleCmds, handleFrame2CmdDic[i] or 0) end local msgReq = battle_common_pb.C2GUploadFrameStatistic() msgReq.gRoomId = gRoomId msgReq.data = statistic:SerializeToString() NetManager.SendMessage(MessageEnums.MessageC2GUploadFrameStatistic,msgReq) private.ClearCacheFrame2CmdInfo() end function private.ClearCacheFrame2CmdInfo() private.cacheFrame2CmdInfo = {} end function FrameCmdStatistic_Model.OnShutdown() if private.timerHandle then TimerUtil.Remove(private.timerHandle) end end return FrameCmdStatistic_Model