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(NFrame.NFGUID xID, NFMsg.EGameMsgID unMsgID, MemoryStream stream) { mxData.player_id = NFNetController.NFToPB(xID); mxData.msg_data = stream.ToArray(); mxBody.SetLength(0); mxSerializer.Serialize(mxBody, mxData); mxHead.unMsgID = (UInt16)unMsgID; mxHead.unDataLen = (UInt32)mxBody.Length + (UInt32)ConstDefine.NF_PACKET_HEAD_SIZE; byte[] bodyByte = mxBody.ToArray(); byte[] headByte = mxHead.EnCode(); byte[] sendBytes = new byte[mxHead.unDataLen]; headByte.CopyTo(sendBytes, 0); bodyByte.CopyTo(sendBytes, headByte.Length); mxNetController.mxNetClient.SendBytes(sendBytes); ///////////////////////////////////////////////////////////////// NFLog.Instance.Log(NFLog.LOG_LEVEL.INFO, "SendMsg:" + unMsgID); }
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); } }
public void SendMsg(NFMsg.EGameMsgID unMsgID, MemoryStream stream) { //NFMsg.MsgBase mxData.player_id = mHelpModule.NFToPB(mLoginModule.mRoleID); mxData.msg_data = 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(); byte[] sendBytes = new byte[mxHead.unDataLen]; headByte.CopyTo(sendBytes, 0); bodyByte.CopyTo(sendBytes, headByte.Length); mNetClient.SendBytes(sendBytes); ///////////////////////////////////////////////////////////////// }