/// <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); }
/// <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))); }
/// <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); }
/// <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); }
/// <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)); }