public void SendMsg(int unMsgID, MemoryStream stream) { //Debug.Log("send message:" + unMsgID); if (mNetClient != null) { //NFMsg.MsgBase mxData.PlayerId = mHelpModule.NFToPB(mLoginModule.mRoleID); mxData.MsgData = ByteString.CopyFrom(stream.ToArray()); mxBody.SetLength(0); mxData.WriteTo(mxBody); mxHead.unMsgID = (UInt16)unMsgID; mxHead.unDataLen = (UInt32)mxBody.Length + (UInt32)ConstDefine.NF_PACKET_HEAD_SIZE; byte[] bodyByte = mxBody.ToArray(); byte[] headByte = mxHead.EnCode(); Array.Clear(sendBytes, 0, ConstDefine.NF_PACKET_BUFF_SIZE); headByte.CopyTo(sendBytes, 0); bodyByte.CopyTo(sendBytes, headByte.Length); mNetClient.SendBytes(sendBytes, bodyByte.Length + headByte.Length); } ///////////////////////////////////////////////////////////////// }
public void SendMsg(int unMsgID) { if (mNetClient != null) { //NFMsg.MsgBase mxData.PlayerId = mHelpModule.NFToPB(mLoginModule.mRoleID); mxBody.SetLength(0); mxData.WriteTo(mxBody); mxHead.unMsgID = (UInt16)unMsgID; mxHead.unDataLen = (UInt32)mxBody.Length + (UInt32)ConstDefine.NF_PACKET_HEAD_SIZE; byte[] bodyByte = mxBody.ToArray(); byte[] headByte = mxHead.EnCode(); Array.Clear(sendBytes, 0, ConstDefine.NF_PACKET_BUFF_SIZE); headByte.CopyTo(sendBytes, 0); bodyByte.CopyTo(sendBytes, headByte.Length); mNetClient.SendBytes(sendBytes, bodyByte.Length + headByte.Length); } }