availableMicroBytes method

int availableMicroBytes({
  1. required String nodeId,
  2. required NodeRole role,
  3. List<String>? groupIds,
})

Returns the number of bytes remaining for micro-messages after encoding the base metadata (groups, role, node prefix).

If negative, the base metadata alone exceeds the limit.

Implementation

int availableMicroBytes({
  required String nodeId,
  required NodeRole role,
  List<String>? groupIds,
}) {
  // Base length + 1 for the pipe delimiter before the micro field
  final baseLength = encodedLength(
    nodeId: nodeId,
    role: role,
    groupIds: groupIds,
  );
  // +1 for the pipe delimiter that would precede the micro-message
  return kEndpointNameMaxBytes - baseLength - 1;
}