Esempio n. 1
0
 /// <summary>
 /// Reads the next specified number of bytes from the buffer.
 /// </summary>
 /// <param name="readSize">The number of bytes to read.</param>
 /// <returns>The array of read bytes.</returns>
 public byte[] ReadBytes(int readSize)
 {
     PreRead();
     byte[] bytes = NetBufferIO.ReadBytes(data, position, readSize);
     position += readSize;
     return(bytes);
 }
Esempio n. 2
0
 // WRITING //
 #region Writing
 /// <summary>
 /// Writes a byte to the buffer.
 /// </summary>
 /// <param name="value">The byte.</param>
 public void Write(byte value)
 {
     PreWrite();
     NetBufferIO.MakeRoom(ref data, 1, position);
     data[position] = value;
     position++;
     AfterWrite();
 }
Esempio n. 3
0
        /// <summary>
        /// Peeks the next string.
        /// </summary>
        /// <returns>The next string.</returns>
        public string PeekString()
        {
            /*  String Formatting
             * Int16 length
             * bytes...
             */

            short stringLength = PeekInt16();

            return(Encoding.Unicode.GetString(NetBufferIO.ReadBytes(data, position + 2, stringLength)));
        }
Esempio n. 4
0
        /// <summary>
        /// Writes a string to the buffer.
        /// </summary>
        /// <param name="value">The string.</param>
        public void Write(string value)
        {
            /*  String Formatting
             * Int16 length
             * bytes...
             */

            byte[] strBytes = Encoding.Unicode.GetBytes(value);
            Write((short)strBytes.Length);                                   // Write length
            NetBufferIO.WriteBytes(strBytes, ref data, ref position, 0, -1); // Write string
            AfterWrite();
        }
Esempio n. 5
0
        /// <summary>
        /// Reads the next string from the buffer.
        /// </summary>
        /// <returns>The next string.</returns>
        public string ReadString()
        {
            /*  String Formatting
             * Int16 length
             * bytes...
             */

            short  stringLength = ReadInt16(); // This is done first to ensure position is advanced
            string str          = Encoding.Unicode.GetString(NetBufferIO.ReadBytes(data, position, stringLength));

            position += stringLength;
            return(str);
        }
Esempio n. 6
0
 /// <summary>
 /// Peeks the specified bytes into a buffer.
 /// </summary>
 /// <param name="buffer">The buffer to read the peeked bytes into.</param>
 /// <param name="offset">The starting point to peek from.</param>
 /// <param name="readSize">The number of bytes to peek.</param>
 public void PeekBytes(ref byte[] buffer, int offset, int readSize)
 {
     PreRead();
     NetBufferIO.ReadBytes(data, ref buffer, offset, readSize);
 }
Esempio n. 7
0
 /// <summary>
 /// Reads the specified bytes from the buffer.
 /// </summary>
 /// <param name="offset">The starting point to read from. (inclusive)</param>
 /// <param name="readSize">The number of bytes to read.</param>
 /// <returns>The array of read bytes.</returns>
 public byte[] ReadBytes(int offset, int readSize)
 {
     PreRead();
     return(NetBufferIO.ReadBytes(data, offset, readSize));
 }
Esempio n. 8
0
 /// <summary>
 /// Writes an unsigned Int64 to the buffer.
 /// </summary>
 /// <param name="value">The unsigned Int64.</param>
 public void Write(ulong value)
 {
     PreWrite();
     NetBufferIO.WriteBytes(BitConverter.GetBytes(value), ref data, ref position, 0, -1);
     AfterWrite();
 }
Esempio n. 9
0
 /// <summary>
 /// Writes the specified bytes to the buffer.
 /// </summary>
 /// <param name="bytes">The bytes to write.</param>
 /// <param name="offset">The offset to start from in the bytes to write.</param>
 /// <param name="readSize">The length to write from the bytes to the buffer.</param>
 public void WriteBytes(byte[] bytes, int offset, int readSize)
 {
     PreWrite();
     NetBufferIO.WriteBytes(bytes, ref data, ref position, offset, readSize);
     AfterWrite();
 }
Esempio n. 10
0
 /// <summary>
 /// Writes the specified bytes to the buffer
 /// </summary>
 /// <param name="bytes">The bytes.</param>
 public void WriteBytes(byte[] bytes)
 {
     PreWrite();
     NetBufferIO.WriteBytes(bytes, ref data, ref position, 0, bytes.Length);
     AfterWrite();
 }