Ejemplo n.º 1
0
        //解包数据(data内容,写在对象里面)
        public bool Unpack(byte[] buffer, int offset, int bufferLen, MemPool pool)
        {
            int nPose = offset;

            serverID = buffer[nPose];
            ++nPose;
            msgID  = BitConverter.ToUInt16(buffer, nPose);
            nPose += 2;
            try
            {
                int nLen = bufferLen - MESSAGE_HEAD_LEN;
                recivedata = pool.Aloc(nLen);//new byte[nLen];
                Array.Copy(buffer, offset + MESSAGE_HEAD_LEN, recivedata.item.data, 0, nLen);
                recivedata.item.nLen = nLen;
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);
            }
            return(true);
        }