Exemple #1
0
        public void SendToServerByPB(NFMsg.EGameMsgID unMsgID, MemoryStream stream)
        {
            NFMsg.MsgBase xData = new NFMsg.MsgBase();
            xData.player_id = mHelpModule.NFToPB(mOwnerID);
            xData.msg_data  = ByteString.AttachBytes(stream.ToArray());

            MemoryStream body = new MemoryStream();

            xData.WriteTo(body);

            MemoryStream pack   = new MemoryStream();
            BinaryWriter writer = new BinaryWriter(pack);
            UInt32       msgLen = (UInt32)body.Length + (UInt32)ConstDefine.NF_PACKET_HEAD_SIZE;

            writer.Write(NFCNet.ConvertUint16((UInt16)unMsgID));
            writer.Write(NFCNet.ConvertUint32((UInt32)msgLen));
            body.WriteTo(pack);

            NFCNet.Instance().sendMsg(pack);
        }
Exemple #2
0
        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);

            /////////////////////////////////////////////////////////////////
        }