Beispiel #1
0
        public int ReadInteger(ref int position)
        {
            int value = BigEndian.ToInt32(_bodyBuffer, position);

            position += BigEndian.GetSize(value);

            _read.Add(value);
            return(value);
        }
Beispiel #2
0
        public HMessage(byte[] data, HDestination destination)
            : this()
        {
            Destination = destination;
            IsCorrupted = (data.Length < 6 ||
                           (BigEndian.ToInt32(data, 0) != data.Length - 4));

            if (!IsCorrupted)
            {
                Header = BigEndian.ToUInt16(data, 4);

                _bodyBuffer = new byte[data.Length - 6];
                Buffer.BlockCopy(data, 6, _bodyBuffer, 0, data.Length - 6);
            }
            else
            {
                _bodyBuffer = data;
            }
            _body.AddRange(_bodyBuffer);
        }