applyToTake method

Future<bool> applyToTake()

Implementation

Future<bool> applyToTake() async {
  ZegoLoggerService.logInfo(
    'applyToTake',
    tag: 'audio room',
    subTag: 'controller.seat',
  );

  if (private.seatManager?.hostsNotifier.value.isEmpty ?? false) {
    ZegoLoggerService.logInfo(
      'Failed to apply for take seat, host is not exist',
      tag: 'audio room',
      subTag: 'controller.seat',
    );
    return false;
  }

  return ZegoUIKit()
      .getSignalingPlugin()
      .sendInvitation(
        inviterID: ZegoUIKit().getLocalUser().id,
        inviterName: ZegoUIKit().getLocalUser().name,
        invitees: private.seatManager?.hostsNotifier.value ?? [],
        timeout: 60,
        type: ZegoLiveAudioRoomInvitationType.requestTakeSeat.value,
        data: '',
      )
      .then((ZegoSignalingPluginSendInvitationResult result) {
    ZegoLoggerService.logInfo(
      'apply to take seat finished, code:${result.error?.code}, '
      'message:${result.error?.message}, '
      'invitationID:${result.invitationID}, '
      'errorInvitees:${result.errorInvitees.keys.toList()}',
      tag: 'audio room',
      subTag: 'controller.seat',
    );

    if (result.error != null) {
      private.seatManager?.events.seat.audience?.onTakingRequestFailed
          ?.call();
    }

    return result.error == null;
  });
}