Message class

Provides functionality for converting data to bytes and vice versa.

Constructors

Message()
Initializes a reusable Message instance.

Properties

arrayLengthName String
The name of an array length value.
final
boolName String
The name of a bool value.
final
byteName String
The name of a byte value.
final
bytesInUse int
How many of this message's bytes are in use. Rounds up to the next byte because only whole bytes can be sent.
no setter
data Uint64List
no setter
doubleName String
The name of a double value.
final
floatName String
The name of a float value.
final
hashCode int
The hash code for this object.
no setterinherited
intName String
The name of an int value.
final
longName String
The name of a long value.
final
maxPayloadSize int
Returns the maximal payload size allowed for messages
getter/setter pair
readBits int
How many bits have been retrieved from the message.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sByteName String
The name of a sbyte value.
final
sendMode MessageSendMode
no setter
shortName String
The name of a short value.
final
stringName String
The name of a string value.
final
uIntName String
The name of a uint value.
final
uLongName String
The name of a ulong value.
final
unreadBits int
How many unretrieved bits remain in the message.
no setter
unwrittenBits int
How many more bits can be added to the message.
no setter
uShortName String
The name of a ushort value.
final
writtenBits int
How many bits have been added to the message.
no setter

Methods

addBitsByte(int bitfield, int amount) Message
Adds up to 8 of the given bits to the message.
addBitsUint(int bitfield, int amount) Message
Adds up to 32 of the given bits to the message.
addBitsUlong(int bitfield, int amount) Message
Adds up to 64 of the given bits to the message.
addBitsUshort(int bitfield, int amount) Message
Adds up to 16 of the given bits to the message.
addBool(bool value) Message
Adds a bool to the message.
addBools(BoolList array, [bool includeLength = true]) Message
Adds a BoolList to the message.
addByte(int value) Message
Adds a byte to the message.
addBytes(Uint8List array, [bool includeLength = true]) Message
Adds a Uint8List to the message.
addBytesWithAmount(Uint8List array, int startIndex, int amount, [bool includeLength = true]) Message
Adds a Uint8List to the message.
addDouble(double value) Message
Adds a double to the message.
addDoubles(Float64List array, [bool includeLength = true]) Message
Adds a Float64List to the message.
addFloat(double value) Message
Adds a float to the message.
addFloats(Float32List array, [bool includeLength = true]) Message
Adds a Float32List to the message.
addInt(int value) Message
Adds an int to the message.
addInts(Int32List array, [bool includeLength = true]) Message
Adds an int array message.
addLong(int value) Message
Adds a long to the message.
addLongs(Int64List array, [bool includeLength = true]) Message
Adds a Int64List to the message.
addMessage(Message message) Message
Adds message's unread bits to the message.
addMessageWithBit(Message message, int amount, int startBit) Message
Adds a range of bits from message to the message.
addSByte(int value) Message
Adds an sbyte to the message.
addSBytes(Int8List array, [bool includeLength = true]) Message
Adds an Int8List to the message.
addShort(int value) Message
Adds a short to the message.
addShorts(Int16List array, [bool includeLength = true]) Message
Adds a Int16List to the message.
addString(String value) Message
Adds a String to the message.
addStrings(List<String> array, [bool includeLength = true]) Message
Adds a String array to the message.
addUInt(int value) Message
Adds a uint to the message.
addUInts(Uint32List array, [bool includeLength = true]) Message
Adds a Uint32List to the message.
addULong(int value) Message
Adds a ulong to the message.
addULongs(Uint64List array, [bool includeLength = true]) Message
Adds a Uint64List to the message.
addUShort(int value) Message
Adds a ushort to the message.
addUShorts(Uint16List array, [bool includeLength = true]) Message
Adds a Uint16List to the message.
addVarLong(int value) Message
Adds a positive or negative number to the message, using fewer bits for smaller values.
addVarULong(int value) Message
Adds a positive number to the message, using fewer bits for smaller values.
getBitsByte(int amount) → (Message, int)
Retrieves the next amount bits (up to 8) from the message.
getBitsUint(int amount) → (Message, int)
Retrieves the next amount bits (up to 32) from the message.
getBitsUlong(int amount) → (Message, int)
Retrieves the next amount bits (up to 64) from the message.
getBitsUshort(int amount) → (Message, int)
Retrieves the next amount bits (up to 16) from the message.
getBool() bool
Retrieves a bool from the message.
getBools() → BoolList
Retrieves a BoolList from the message.
getBoolsWithAmount(int amount) → BoolList
Retrieves a BoolList from the message.
getBoolsWithList(int amount, BoolList intoArray, [int startIndex = 0]) → void
Populates a BoolList with bools retrieved from the message.
getByte() int
Retrieves a byte from the message.
getBytes() Uint8List
Retrieves a Uint8List from the message.
getBytesWithAmount(int amount) Uint8List
Retrieves a Uint8List from the message.
getBytesWithList(int amount, Uint8List intoArray, [int startIndex = 0]) → void
Populates a Uint8List with bytes retrieved from the message.
getDouble() double
Retrieves a double from the message.
getDoubles() Float64List
Retrieves a Float64List from the message.
getDoublesWithAmount(int amount) Float64List
Retrieves a Float64List from the message.
getDoublesWithList(int amount, Float64List intoArray, [int startIndex = 0]) → void
Populates a Float64List with doubles retrieved from the message.
getFloat() double
Retrieves a float from the message.
getFloats() Float32List
Retrieves a Float32List from the message.
getFloatsWithAmount(int amount) Float32List
Retrieves a Float32List from the message.
getFloatsWithList(Float32List intoArray, [int startIndex = 0]) → void
Populates a Float32List with floats retrieved from the message.
getFloatsWithListAndAmount(int amount, Float32List intoArray, [int startIndex = 0]) → void
Populates a Float32List with floats retrieved from the message.
getInt() int
Retrieves an int from the message.
getInts() Int32List
Retrieves an int array from the message.
getIntsWithAmount(int amount) Int32List
Retrieves an int array from the message.
getIntsWithList(int amount, Int32List intoArray, [int startIndex = 0]) → void
Populates an int array with ints retrieved from the message.
getLong() int
Retrieves a long from the message.
getLongs() Int64List
Retrieves a Int64List from the message.
getLongsWithAmount(int amount) Int64List
Retrieves a Int64List from the message.
getLongsWithList(Int64List intoArray, [int startIndex = 0]) → void
Populates a Int64List with longs retrieved from the message.
getLongsWithListAndAmount(int amount, Int64List intoArray, [int startIndex = 0]) → void
Populates a Int64List with longs retrieved from the message.
getSByte() int
Retrieves an sbyte from the message.
getSBytes() Int8List
Retrieves an Int8List from the message.
getSBytesWithAmount(int amount) Int8List
Retrieves an Int8List from the message.
getSBytesWithList(int amount, Int8List intArray, [int startIndex = 0]) → void
Populates a Int8List with bytes retrieved from the message.
getShort() int
Retrieves a short from the message.
getShorts() Int16List
Retrieves a Int16List from the message.
getShortsWithAmount(int amount) Int16List
Retrieves a Int16List from the message.
getShortsWithList(int amount, Int16List intoArray, [int startIndex = 0]) → void
Populates a Int16List with shorts retrieved from the message.
getString() String
Retrieves a String from the message.
getStrings() List<String>
Retrieves a String array from the message.
getStringsWithAmount(int amount) List<String>
Retrieves a String array from the message.
getStringsWithList(int amount, List<String> intoArray, [int startIndex = 0]) → void
Populates a String array with strings retrieved from the message.
getUInt() int
Retrieves a uint from the message.
getUInts() Uint32List
Retrieves a Uint32List from the message.
getUIntsWithAmount(int amount) Uint32List
Retrieves a Uint32List from the message.
getUIntsWithList(int amount, Uint32List intoArray, [int startIndex = 0]) → void
Populates a Uint32List with uints retrieved from the message.
getULong() int
Retrieves a ulong from the message.
getULongs() Uint64List
Retrieves a Uint64List from the message.
getULongsWithAmount(int amount) Uint64List
Retrieves a Uint64List from the message.
getULongsWithList(Uint64List intoArray, [int startIndex = 0]) → void
Populates a Uint64List with ulongs retrieved from the message.
getULongsWithListAndAmount(int amount, Uint64List intoArray, [int startIndex = 0]) → void
Populates a Uint64List with ulongs retrieved from the message.
getUShort() int
Retrieves a ushort from the message.
getUShorts() Uint16List
Retrieves a Uint16List from the message.
getUShortsWithAmount(int amount) Uint16List
Retrieves a Uint16List from the message.
getUShortsWithList(int amount, Uint16List intoArray, [int startIndex = 0]) → void
Populates a Uint16List with ushorts retrieved from the message.
getVarLong() int
Retrieves a positive or negative number from the message, using fewer bits for smaller values.
getVarULong() int
Retrieves a positive number from the message, using fewer bits for smaller values.
initWithByte(int firstByte, int contentLength) → (Message, MessageHeader)
Initializes the message so that it can be used for receiving/handling.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
peekBitsByte(int amount, int startBit) → (Message, int)
Retrieves up to 8 bits from the specified position in the message.
peekBitsUint(int amount, int startBit) → (Message, int)
Retrieves up to 32 bits from the specified position in the message.
peekBitsUlong(int amount, int startBit) → (Message, int)
Retrieves up to 64 bits from the specified position in the message.
peekBitsUshort(int amount, int startBit) → (Message, int)
Retrieves up to 16 bits from the specified position in the message.
release() → void
Returns the message instance to the internal pool so it can be reused.
reserveBits(int amount) Message
Moves the message's internal write position by the given amount of bits, reserving them so they can be set at a later time.
setBits(int bitfield, int amount, int startBit) Message
Sets up to 64 bits at the specified position in the message.
setHeader(MessageHeader header) → void
Sets the message's header byte to the given header and determines the appropriate MessageSendMode and read/write positions.
skipBits(int amount) Message
Moves the message's internal read position by the given amount of bits, skipping over them.
toString() String
A string representation of this object.
inherited

Operators

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

Static Properties

byteBuffer Uint8List
An intermediary buffer to help convert data to a byte array when sending.
getter/setter pair
instancesPerPeer int
How many messages to add to the pool for each Server or Client instance that is started.
getter/setter pair
maxSize int
Returns the maximum message size allowed
no setter

Static Methods

create() Message
Gets a completely empty message instance with no header.
createFromEnum(MessageSendMode sendMode, Enum id) Message
Gets a message instance that can be used for sending.
createFromHeader(MessageHeader header) Message
Gets a message instance that can be used for sending.
createFromInt(MessageSendMode sendMode, int id) Message
Gets a message instance that can be used for sending.
createWithSendMode(MessageSendMode sendMode) Message
Gets a message instance that can be used for sending.
initialize() → void
trimPool() → void
Trims the message pool to a more appropriate size for how many Server and Client instances are currently running.

Constants

headerBitmask → const int
A bitmask that, when applied, only keeps the bits corresponding to the MessageHeader value.
headerBits → const int
The number of bits used by the MessageHeader.
maxHeaderSize → const int
The maximum number of bits required for a message's header.
minNotifyBytes → const int
The minimum number of bytes contained in a notify message.
minReliableBytes → const int
The minimum number of bytes contained in a reliable message.
minUnreliableBytes → const int
The minimum number of bytes contained in an unreliable message.
notifyHeaderBits → const int
The header size for notify messages.
reliableHeaderBits → const int
The header size for reliable messages. Does not count the 2 bytes used for the message ID.
unreliableHeaderBits → const int
The header size for unreliable messages. Does not count the 2 bytes used for the message ID.