示例#1
0
        public void testZipMsg()
        {
            byte[] outBytes = null;
            uint outSize = 0;

            byte[] inBytes = null;
            uint inSize = 0;

            ByteBuffer pByteBuffer = new ByteBuffer();
            UnitTestStrCmd pUnitTestCmd = new UnitTestStrCmd();

            // 发送第一个数据包
            pUnitTestCmd.testStr = "测试数据";
            pByteBuffer.clear();
            pUnitTestCmd.serialize(pByteBuffer);

            Compress.CompressData(pByteBuffer.dynBuff.buff, 0, pByteBuffer.length, ref outBytes, ref outSize);
            Compress.DecompressData(outBytes, 0, outSize, ref inBytes, ref inSize);

            pByteBuffer.clear();
            pByteBuffer.writeBytes(inBytes, 0, inSize);
            pByteBuffer.position = 0;
            pUnitTestCmd.derialize(pByteBuffer);

            UAssert.DebugAssert(pUnitTestCmd.testStr != "测试数据");
        }
示例#2
0
        public void serialize(ByteBuffer bu)
        {
            bu.writeUnsignedInt32(qwThisID);
            bu.writeUnsignedInt32(dwObjectID);
            pos = new stObjectLocation();
            pos.serialize(bu);

            bu.writeUnsignedInt32(mpcost);
            bu.writeUnsignedInt32(damage);
            bu.writeUnsignedInt32(hp);
            bu.writeUnsignedInt32(maxhp);
            bu.writeUnsignedInt32(dur);

            bu.writeUnsignedInt8(magicDamAdd);
            bu.writeUnsignedInt8(overload);
            bu.writeUnsignedInt32(armor);
            bu.writeUnsignedInt8(attackTimes);
            bu.writeUnsignedInt8(equipOpen);

            bu.writeUnsignedInt8(side);
            bu.writeUnsignedInt32(popHpValue);
            bu.writeUnsignedInt32(popDamValue);

            uint len = ((int)StateID.CARD_STATE_MAX + 7) / 8;

            state = new byte[len];
            bu.writeBytes(state, 0, len);
        }
示例#3
0
        public void serialize(ByteBuffer bu)
        {
            bu.writeUnsignedInt32(qwThisID);
            bu.writeUnsignedInt32(dwObjectID);
            pos = new stObjectLocation();
            pos.serialize(bu);

            bu.writeUnsignedInt32(mpcost);
            bu.writeUnsignedInt32(damage);
            bu.writeUnsignedInt32(hp);
            bu.writeUnsignedInt32(maxhp);
            bu.writeUnsignedInt32(dur);

            bu.writeUnsignedInt8(magicDamAdd);
            bu.writeUnsignedInt8(overload);
            bu.writeUnsignedInt32(armor);
            bu.writeUnsignedInt8(attackTimes);
            bu.writeUnsignedInt8(equipOpen);

            bu.writeUnsignedInt8(side);
            bu.writeUnsignedInt32(popHpValue);
            bu.writeUnsignedInt32(popDamValue);

            uint len = ((int)StateID.CARD_STATE_MAX + 7) / 8;
            state = new byte[len];
            bu.writeBytes(state, 0, len);
        }
示例#4
0
        // 加载一个表完成
        public void onLoadEventHandle(IDispatchObject dispObj)
        {
            m_res = dispObj as ResItem;
            if (m_res.refCountResLoadResultNotify.resLoadState.hasSuccessLoaded())
            {
                Ctx.m_instance.m_logSys.debugLog_1(LangItemID.eItem0, m_res.GetPath());

                byte[] bytes = m_res.getBytes("");
                if (bytes != null)
                {
                    m_byteArray = Ctx.m_instance.m_factoryBuild.buildByteBuffer();
                    m_byteArray.clear();
                    m_byteArray.writeBytes(bytes, 0, (uint)bytes.Length);
                    m_byteArray.setPos(0);
                    readTable(getTableIDByPath(m_res.GetPath()), m_byteArray);
                }
            }
            else if (m_res.refCountResLoadResultNotify.resLoadState.hasFailed())
            {
                Ctx.m_instance.m_logSys.debugLog_1(LangItemID.eItem1, m_res.GetPath());
            }

            // 卸载资源
            Ctx.m_instance.m_resLoadMgr.unload(m_res.GetPath(), onLoadEventHandle);
        }
示例#5
0
        // 仅仅是获取数据,并不删除
        public void frontBA(ByteBuffer bytearray, uint len)
        {
            bytearray.clear();             // 设置数据为初始值
            if (m_dynBuffer.m_size >= len) // 头部占据 4 个字节
            {
                if (isLinearized())        // 在一段连续的内存
                {
                    bytearray.writeBytes(m_dynBuffer.m_buff, m_first, len);
                }
                else if (m_dynBuffer.m_iCapacity - m_first >= len)
                {
                    bytearray.writeBytes(m_dynBuffer.m_buff, m_first, len);
                }
                else
                {
                    bytearray.writeBytes(m_dynBuffer.m_buff, m_first, m_dynBuffer.m_iCapacity - m_first);
                    bytearray.writeBytes(m_dynBuffer.m_buff, 0, len - (m_dynBuffer.m_iCapacity - m_first));
                }
            }

            bytearray.position = 0;        // 设置数据读取起始位置
        }
 public override void derialize(ByteBuffer bu)
 {
     base.derialize(bu);
     bu.readUnsignedInt32(ref dwUserID);
     bu.readUnsignedInt32(ref loginTempID);
     bu.readMultiByte(ref pstrIP, ProtoCV.MAX_IP_LENGTH, GkEncode.UTF8);
     bu.readUnsignedInt16(ref wdPort);
     keyAux = new ByteBuffer();
     byte[] ret = new byte[256];
     bu.readBytes(ref ret, 256);
     keyAux.writeBytes(ret, 0, 256);
     keyAux.position = 58;
     byte index = 0;
     keyAux.readUnsignedInt8(ref index);
     keyAux.position = index;
     key = new byte[8];
     keyAux.readBytes(ref key, 8);
     bu.readUnsignedInt32(ref state);
 }
示例#7
0
        // 仅仅是获取数据,并不删除
        public void frontBA(ByteBuffer bytearray, uint len)
        {
            bytearray.clear();          // 设置数据为初始值
            if (m_dynBuffer.m_size >= len)          // 头部占据 4 个字节
            {
                if (isLinearized())      // 在一段连续的内存
                {
                    bytearray.writeBytes(m_dynBuffer.m_buff, m_first, len);
                }
                else if (m_dynBuffer.m_iCapacity - m_first >= len)
                {
                    bytearray.writeBytes(m_dynBuffer.m_buff, m_first, len);
                }
                else
                {
                    bytearray.writeBytes(m_dynBuffer.m_buff, m_first, m_dynBuffer.m_iCapacity - m_first);
                    bytearray.writeBytes(m_dynBuffer.m_buff, 0, len - (m_dynBuffer.m_iCapacity - m_first));
                }
            }

            bytearray.position = 0;        // 设置数据读取起始位置
        }
示例#8
0
        // 加载一个表完成
        public void onLoadEventHandle(IDispatchObject dispObj)
        {
            m_res = dispObj as ResItem;
            if (m_res.refCountResLoadResultNotify.resLoadState.hasSuccessLoaded())
            {
                Ctx.m_instance.m_logSys.debugLog_1(LangItemID.eItem0, m_res.GetPath());

                byte[] bytes = m_res.getBytes("");
                if (bytes != null)
                {
                    m_byteArray = Ctx.m_instance.m_factoryBuild.buildByteBuffer();
                    m_byteArray.clear();
                    m_byteArray.writeBytes(bytes, 0, (uint)bytes.Length);
                    m_byteArray.setPos(0);
                    readTable(getTableIDByPath(m_res.GetPath()), m_byteArray);
                }
            }
            else if (m_res.refCountResLoadResultNotify.resLoadState.hasFailed())
            {
                Ctx.m_instance.m_logSys.debugLog_1(LangItemID.eItem1, m_res.GetPath());
            }

            // 卸载资源
            Ctx.m_instance.m_resLoadMgr.unload(m_res.GetPath(), onLoadEventHandle);
        }