addLabelData method

Future<void> addLabelData({
  1. required String label,
  2. required String producerId,
})

Implementation

Future<void> addLabelData({
  required String label,
  required String producerId,
}) async {
  _labelsToProducerId[label] = {'producerId': producerId};

  try {
    bool autoConsume = Room.getInstance().autoConsume;
    LocalPeer localPeer = LocalPeer.getInstance();

    if (autoConsume) {
      logger.d("AUTO CONSUME IS ENABLED, CONSUMING THE PRODUCER'S STREAM");

      await localPeer.consume({
        'appData': {},
        'label': label,
        'peerId': peerId,
      });
    } else {
      emit('stream-available', {
        'label': label,
        'labelData': {'producerId': producerId},
      });
    }
  } catch (error) {
    logger.e('❌ Error While Consuming | Error: $error');
    emit('stream-available', {
      'label': label,
      'labelData': {'producerId': producerId},
    });
  }
}