Class ArrayPacketBuffer
- java.lang.Object
-
- io.github.joealisson.mmocore.WritableBuffer
-
- io.github.joealisson.mmocore.internal.InternalWritableBuffer
-
- io.github.joealisson.mmocore.internal.ArrayPacketBuffer
-
- All Implemented Interfaces:
Buffer,ReadableBuffer
public class ArrayPacketBuffer extends InternalWritableBuffer implements ReadableBuffer
-
-
Constructor Summary
Constructors Constructor Description ArrayPacketBuffer(int size, ResourcePool resourcePool)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intlimit()voidlimit(int newLimit)Change the buffer's limitvoidmark()intposition()voidposition(int pos)bytereadByte()Reads raw byte from the bufferbytereadByte(int index)Read byte from the buffer at index.voidreadBytes(byte[] dst)voidreadBytes(byte[] dst, int offset, int length)charreadChar()doublereadDouble()floatreadFloat()intreadInt()Reads int from the buffer.intreadInt(int index)Read int from the buffer at index.longreadLong()shortreadShort()Reads short from the buffer.shortreadShort(int index)Read short from the buffer at index.voidreleaseResources()intremaining()java.nio.ByteBuffer[]toByteBuffers()voidwriteByte(byte value)Write a byte to the buffer.voidwriteByte(int index, byte value)Write byte to the buffer at index.voidwriteBytes(byte[] bytes)Write byte[] to the buffer.voidwriteChar(char value)Write char to the buffer.
16 bit charvoidwriteDouble(double value)Write double to the buffer.voidwriteFloat(float value)Write float to the buffer.voidwriteInt(int value)Write int to the buffer.voidwriteInt(int index, int value)Write int to the buffer at index.voidwriteLong(long value)Write long to the buffer.voidwriteShort(int index, short value)Write int to the buffer at index.voidwriteShort(short value)Write short to the buffer.-
Methods inherited from class io.github.joealisson.mmocore.internal.InternalWritableBuffer
arrayBacked, dynamicOf, dynamicOf
-
Methods inherited from class io.github.joealisson.mmocore.WritableBuffer
writeByte, writeByte, writeInt, writeShort, writeShort, writeSizedString, writeString
-
-
-
-
Constructor Detail
-
ArrayPacketBuffer
public ArrayPacketBuffer(int size, ResourcePool resourcePool)
-
-
Method Detail
-
writeByte
public void writeByte(byte value)
Description copied from class:WritableBufferWrite a byte to the buffer.
8bit integer (00) If the underlying data array can't hold a new byte its size is increased 20%- Specified by:
writeBytein classWritableBuffer- Parameters:
value- to be written
-
writeByte
public void writeByte(int index, byte value)Description copied from interface:BufferWrite byte to the buffer at index.
8bit integer (00)
-
writeBytes
public void writeBytes(byte[] bytes)
Description copied from class:WritableBufferWrite byte[] to the buffer.
8bit integer array (00 ...)- Specified by:
writeBytesin classWritableBuffer- Parameters:
bytes- to be written
-
writeShort
public void writeShort(short value)
Description copied from class:WritableBufferWrite short to the buffer.
16bit integer (00 00)- Specified by:
writeShortin classWritableBuffer- Parameters:
value- to be written
-
writeShort
public void writeShort(int index, short value)Description copied from interface:BufferWrite int to the buffer at index.
16bit integer (00 00)- Specified by:
writeShortin interfaceBuffer- Parameters:
index- index to write tovalue- to be written
-
writeChar
public void writeChar(char value)
Description copied from class:WritableBufferWrite char to the buffer.
16 bit char- Specified by:
writeCharin classWritableBuffer- Parameters:
value- the char to be put on data.
-
writeInt
public void writeInt(int value)
Description copied from class:WritableBufferWrite int to the buffer.
32bit integer (00 00 00 00)- Specified by:
writeIntin classWritableBuffer- Parameters:
value- to be written
-
writeInt
public void writeInt(int index, int value)Description copied from interface:BufferWrite int to the buffer at index.
32bit integer (00 00 00 00)
-
writeFloat
public void writeFloat(float value)
Description copied from class:WritableBufferWrite float to the buffer.
32bit float point number (00 00 00 00)- Specified by:
writeFloatin classWritableBuffer- Parameters:
value- to be written
-
writeLong
public void writeLong(long value)
Description copied from class:WritableBufferWrite long to the buffer.
64bit integer (00 00 00 00 00 00 00 00)- Specified by:
writeLongin classWritableBuffer- Parameters:
value- to be written
-
writeDouble
public void writeDouble(double value)
Description copied from class:WritableBufferWrite double to the buffer.
64bit double precision float (00 00 00 00 00 00 00 00)- Specified by:
writeDoublein classWritableBuffer- Parameters:
value- to be written
-
position
public int position()
- Specified by:
positionin classInternalWritableBuffer
-
position
public void position(int pos)
- Specified by:
positionin classInternalWritableBuffer
-
readByte
public byte readByte()
Description copied from interface:ReadableBufferReads raw byte from the buffer- Specified by:
readBytein interfaceReadableBuffer- Returns:
- byte read
-
readByte
public byte readByte(int index)
Description copied from interface:BufferRead byte from the buffer at index.
8bit integer (00)
-
readShort
public short readShort()
Description copied from interface:ReadableBufferReads short from the buffer.
16bit integer (00 00)- Specified by:
readShortin interfaceReadableBuffer- Returns:
- short read
-
readShort
public short readShort(int index)
Description copied from interface:BufferRead short from the buffer at index.
16bit integer (00 00)
-
readChar
public char readChar()
- Specified by:
readCharin interfaceReadableBuffer
-
readInt
public int readInt()
Description copied from interface:ReadableBufferReads int from the buffer.
32bit integer (00 00 00 00)- Specified by:
readIntin interfaceReadableBuffer- Returns:
- int read
-
readFloat
public float readFloat()
- Specified by:
readFloatin interfaceReadableBuffer
-
readLong
public long readLong()
- Specified by:
readLongin interfaceReadableBuffer
-
readDouble
public double readDouble()
- Specified by:
readDoublein interfaceReadableBuffer
-
readBytes
public void readBytes(byte[] dst)
- Specified by:
readBytesin interfaceReadableBuffer
-
readBytes
public void readBytes(byte[] dst, int offset, int length)- Specified by:
readBytesin interfaceReadableBuffer
-
readInt
public int readInt(int index)
Description copied from interface:BufferRead int from the buffer at index.
32bit integer (00 00 00 00)
-
limit
public void limit(int newLimit)
Description copied from interface:BufferChange the buffer's limit
-
mark
public void mark()
- Specified by:
markin classInternalWritableBuffer
-
toByteBuffers
public java.nio.ByteBuffer[] toByteBuffers()
- Specified by:
toByteBuffersin classInternalWritableBuffer
-
releaseResources
public void releaseResources()
- Specified by:
releaseResourcesin classInternalWritableBuffer
-
remaining
public int remaining()
- Specified by:
remainingin interfaceReadableBuffer
-
-