public void Parse(Stream source) { CMsg cmsg = ProtoBuf.Serializer.Deserialize <CMsg>(source); int cmd = cmsg.cmd; int dest = cmsg.dest; long serverTime = cmsg.serverTime; byte[] body = cmsg.body; //消息号保存进队列 PBNO _pb = new PBNO(); _pb.msg = cmsg; _pb.pbInstance = null; //分发协议去解析 _pb.pbInstance = pb.ParseData(dest, cmd, body); if (IsOftenData(dest, cmd)) { net.PushDataScene(_pb); } else { net.PushDataQueue(_pb); } Debug.Log("收到消息 dest=" + dest + ",cmd=" + cmd); }
//解析协议信息 private void ParseDataByPbManage(Stream source) { CMsg cmsg = ProtoBuf.Serializer.Deserialize <CMsg>(source); int cmd = cmsg.cmd; int dest = cmsg.dest; long serverTime = cmsg.serverTime; byte[] body = cmsg.body; //消息号保存进队列 PBNO _pb = new PBNO(); _pb.msg = cmsg; //分发协议去解析 pbManage.ParseData(dest, cmd, body); if (IsOftenData(dest, cmd)) { recDataScene.Enqueue(_pb); } else { recDataQueue.Enqueue(_pb); } Debug.Log("收到消息 dest=" + dest + ",cmd=" + cmd); }