Class DynamicPacketBuffer
- java.lang.Object
-
- io.github.joealisson.mmocore.WritableBuffer
-
- io.github.joealisson.mmocore.internal.InternalWritableBuffer
-
- io.github.joealisson.mmocore.internal.DynamicPacketBuffer
-
- All Implemented Interfaces:
Buffer
public class DynamicPacketBuffer extends InternalWritableBuffer
-
-
Constructor Summary
Constructors Constructor Description DynamicPacketBuffer(java.nio.ByteBuffer buffer, ResourcePool resourcePool)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcapacity()intlimit()voidlimit(int newLimit)Change the buffer's limitvoidmark()intposition()voidposition(int pos)bytereadByte(int index)Read byte from the buffer at index.voidreadBytes(int index, byte[] data)doublereadDouble(int index)floatreadFloat(int index)intreadInt(int index)Read int from the buffer at index.longreadLong(int index)shortreadShort(int index)Read short from the buffer at index.voidreleaseResources()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
-
DynamicPacketBuffer
public DynamicPacketBuffer(java.nio.ByteBuffer buffer, 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)- Parameters:
index- index to write tovalue- to be written
-
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)- 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)- Parameters:
index- index to write tovalue- to be written
-
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(int index)
Description copied from interface:BufferRead byte from the buffer at index.
8bit integer (00)- Parameters:
index- index to read from- Returns:
- the byte value at the index.
-
readBytes
public void readBytes(int index, byte[] data)
-
readShort
public short readShort(int index)
Description copied from interface:BufferRead short from the buffer at index.
16bit integer (00 00)- Parameters:
index- index to read from- Returns:
- the short value at index.
-
readInt
public int readInt(int index)
Description copied from interface:BufferRead int from the buffer at index.
32bit integer (00 00 00 00)- Parameters:
index- index to read from- Returns:
- the int value at index.
-
readFloat
public float readFloat(int index)
-
readLong
public long readLong(int index)
-
readDouble
public double readDouble(int index)
-
limit
public int limit()
- Returns:
- the buffer's limit
-
limit
public void limit(int newLimit)
Description copied from interface:BufferChange the buffer's limit- Parameters:
newLimit- the new limit
-
capacity
public int capacity()
-
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
-
-