Exemplo n.º 1
0
        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);
            }

            /////////////////////////////////////////////////////////////////
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
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);

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