encodeMicroMessage method

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

Encodes a micro-message payload into a base64 string suitable for embedding in the endpoint name.

Returns null if the payload is too large to fit in the available byte budget after encoding the base metadata.

Implementation

String? encodeMicroMessage(
  List<int> payload, {
  required String nodeId,
  required NodeRole role,
  List<String>? groupIds,
}) {
  final encoded = base64Encode(payload);
  final available = availableMicroBytes(
    nodeId: nodeId,
    role: role,
    groupIds: groupIds,
  );

  if (encoded.length > available || available <= 0) return null;
  return encoded;
}