void FixedUpdate() { if (!m_inited) { return; } if (m_netState == NetState.Disconnected) { return; } this.NetMainLoop(); //处理超时协议 m_protoUtil.Tick(); //处理收到的回包 m_pkgBuff.Clear(); int count = m_RecvQueue.Count; for (int i = 0; i < count; ++i) { m_pkgBuff.Enqueue(m_RecvQueue.Dequeue()); } m_RecvQueue.Clear(); int countOfMSG = m_pkgBuff.Count; for (int i = 0; i < countOfMSG; i++) { MsgData msg = m_pkgBuff.Dequeue(); if (this.onChkRecvPkg(msg.Cmd)) { m_protoUtil.DispatchEvent(msg); } } //统一清理超时和已经收到的包 m_protoUtil.Clear(); // //收包、网络状态变更检测 // TimeSpan ts = DateTime.Now - updateTime; // int Milliseconds = ts.Milliseconds; // Debug.Log("Update tike " + Milliseconds); // updateTime = DateTime.Now; m_networkHeartBeat.Render(); }