コード例 #1
0
        private bool ParseData(byte[] data)
        {
            var reader = new PacketReader(data);
            var header = reader.ReadLong();
            var id = reader.ReadLong();
            logger.Debug("ID: {0}", id);
            if (IsIncorrectId(id))
            {
                return false;
            }
            this.id = id;
            totalNumberOfParts = reader.ReadByte();
            logger.Debug("TOTAL PARTS: {0}", totalNumberOfParts);
            var number = reader.ReadByte();
            logger.Debug("NUMBER: {0}", number);
            size = reader.ReadShort();
            logger.Debug("SIZE: {0}", size);
            //if (number == 0 && IsPacketCompressed())
            //{
            //    uncompressedSize = reader.ReadLong();
            //    logger.Debug("USIZE: {0}", uncompressedSize);
            //    checkSum = reader.ReadLong();
            //    logger.Debug("SUM: {0}", checkSum);
            //}
            if (number == 0)
            {
                var strangeNumberInFirstPacket = reader.ReadLong();
                logger.Debug("Strange number: {0}", strangeNumberInFirstPacket);
            }

            var payloadPart = reader.GetRest();
            parts.Add(new PacketPartData { Number = number, Data = payloadPart });

            logger.Debug("END PART");

            return true;
        }