//主线程调用,当收到一个整包时. public bool OnReceiveFullPacket(proto_header head, byte[] block) { //Initial uin from first message /* * if (m_SocketInfo.m_Uin == 0 && uin != 0) * { * m_SocketInfo.m_Uin = uin; * * if ( CNetWorkGlobal.Instance.IsDebug ) * Log.info("CNetWorkGlobal", "m_SocketInfo.m_Uin set to: " + uin); * }*/ //如果p2p开通 /* * if (m_Ctrl.UdpClient != null) { * if (m_Ctrl.UdpClient.UIN == 0 && uin != 0) { * m_Ctrl.UdpClient.UIN = (uint)uin; * Log.info(this, "m_Ctrl.P2PClient.UIN set to: " + uin); * } * }*/ if (protoList.ContainsKey(head.shMsgID)) { DkRecProto proto = protoList[head.shMsgID]; proto.respond(head, block); return(true); } else { Debug.LogError("[CNetWorkGlobal][Receive] Can not find registered msg id " + head.shMsgID); return(false); } }
//客户端的P2P消息处理 public bool ReceiveP2P(proto_header head, byte[] block) { //设置p2p if (protoList.ContainsKey(head.shMsgID)) { DkRecProto proto = protoList[head.shMsgID]; proto.isP2P = true; //设置p2p标记 proto.respond(head, block); return(true); } else { Log.info("CNetWorkGlobal", "can not find res msg id " + head.shMsgID); return(false); } }