PacketReader class abstract

Reads different server packets from binary into objects.

Constructors

PacketReader()
PacketReader.fromList(List<int> list)
Create a PacketReader from a integer List. If list is not a Uint8List, we will create one from given list.
factory

Properties

data Uint8List?
List of bytes to read.
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
readByteData ByteData?
_data represented as a ByteData to ease with the reading of various integers and floats.
getter/setter pairinherited
readPosition int
The current read position inside of _byteData;
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
setEndianness Endian
no getterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
readByte({bool signed = false}) int
Reads a single byte at readPosition.
inherited
readDouble({bool signed = false}) double
Reads a 8 byte double starting at readPosition.
inherited
readFloat({bool signed = false}) double
Reads a 4 byte float starting at readPosition.
inherited
readInt({bool signed = false}) int
Reads a 4 byte integer starting at readPosition.
inherited
readLong({bool signed = false}) int
Reads a 8 byte integer starting at readPosition.
inherited
readPacket({PacketCompression compression = PacketCompression.none}) ServerPacket
readShort({bool signed = false}) int
Reads a 2 byte short starting at readPosition.
inherited
readString() String
Read a string where the length is encoded as a var long.
readVarLong({bool signed = false}) Pair<int, int>
Reads a 8 byte variable length long starting at readPosition. The format of this long will be as to LEB128, or better what Minecraft uses. Returns a Pair, in which the first integer is the read value and the second the length of the var-integer in bytes.
inherited
reset(Uint8List list) → void
inherited
resetPosition() → void
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

readPacketFromStream(Stream<Uint8List> stream) Future<ServerPacket>
Read a single packet from a Stream. This Stream will most likely from a Socket, though any Stream will work. This will read multiple chunks from the Stream, until the initially sent packet size is met.