Esempio n. 1
0
        /// <summary>
        /// Writes array of <see cref="byte"/> into packet buffer.
        /// </summary>
        /// <param name="v">Array of <see cref="byte"/> values.</param>
        public unsafe void WriteBytesArray(byte[] v)
        {
            int length = v.Length;

            ValidateBufferSize(length);

            L2Buffer.Copy(v, 0, m_Buffer, m_Offset, length);
            m_Offset += length;
        }
Esempio n. 2
0
        /// <summary>
        /// Reads array of <see cref="byte"/> values from packet buffer.
        /// </summary>
        /// <param name="length">Length of array to read.</param>
        /// <returns>Array of <see cref="byte"/> values.</returns>
        public unsafe byte[] ReadBytesArray(int length)
        {
            byte[] dest = new byte[length];

            fixed(byte *buf = m_Buffer, dst = dest)
            L2Buffer.Copy(buf, length, dst, ref m_Offset);

            return(dest);
        }
Esempio n. 3
0
 /// <summary>
 /// Returns packet buffer.
 /// </summary>
 /// <param name="skipFirstBytesCount">Amount of first bytes to skip.</param>
 /// <returns>Buffer without provided amount of first bytes.</returns>
 public byte[] GetBuffer(int skipFirstBytesCount)
 {
     return(L2Buffer.Copy(m_Buffer, skipFirstBytesCount, new byte[m_Buffer.Length - skipFirstBytesCount], 0, m_Buffer.Length - skipFirstBytesCount));
 }