sendData method

void sendData(
  1. String sendDataTo,
  2. String payload,
  3. String label
)

Implementation

void sendData(
  String sendDataTo,
  String payload,
  String label,
) {
  try {
    if (!checkPermission(permissionTypeCheck: PermissionType.canSendData)) {
      return;
    }

    if (estimateSize(payload) > maxDataMessageSize) {
      logger.e('❌ Data message exceeds 1kb in size');
      return;
    }

    final parsedTo = sendDataTo == '*' ? ['*'] : [sendDataTo];

    socket.publish(
      Request_Request.sendData,
      {
        'to': parsedTo,
        'payload': payload,
        'label': label,
      },
    );
  } catch (error) {
    logger.e('🔔 Error Sending Data | error: $error');
  }
}