Creates a new PacketBuffer
and initalizes the
wrapped buffer to the given size
.
The size of the buffer.
The current index of the buffer.
The wrapped buffer.
The length of the buffer.
The number of bytes between the end of the buffer and the current index.
Reads a single byte from the buffer, returns true
if the byte is 1
and false
otherwise.
Reads a 1 byte integer from the buffer.
Reads 2 bytes to get the length, then reads length
bytes from the buffer.
Reads a 4 byte floating point number from the buffer.
Reads a 4 byte integer from the buffer.
Reads a 2 byte integer from the buffer.
Reads 2 bytes to get the length, reads length
bytes from the buffer, then converts
the result to a utf8 string.
The same as readString()
, but reads 4 bytes for the length.
Reads a 4 byte unsigned integer from the buffer.
Reads a 1 byte unsigned integer from the buffer.
Reads a 2 byte unsigned integer from the buffer.
Resets the bufferIndex
to 0
and allocates a fresh buffer of length DEFAULT_SIZE
to the underlying buffer.
Changes the size of the buffer without affecting the contents.
The new size of the buffer.
Writes a single byte to the buffer. Writes 1
if the value is true
and 0
otherwise.
The value to write.
Writes a 1 byte integer to the buffer.
The value to write.
Writes the length of the array as a 2 byte integer, then writes length
bytes to the buffer.
The value to write.
Writes a 4 byte floating point value to the buffer.
The value to write.
Writes a 4 byte integer to the buffer.
The value to write.
Writes a 2 byte integer to the buffer.
The value to write.
Writes the length of the string as a 2 byte integer, then writes the string to the buffer.
The value to write.
The same as writeString()
, but writes 4 bytes for the length.
The value to write.
Writes a 4 byte unsigned integer to the buffer.
The value to write.
Writes a 1 byte unsigned integer to the buffer.
The value to write.
Writes a 2 byte unsigned integer to the buffer.
The value to write.
Generated using TypeDoc
A wrapper class for providing read/write methods on top of a Buffer.