focusPanelists function

Future<void> focusPanelists(
  1. FocusPanelistsOptions options
)

Focuses the display on panelists only. When enabled, only panelists appear on the grid. Optionally mutes other participants' mic and/or camera.

Example:

await focusPanelists(FocusPanelistsOptions(
  socket: socket,
  roomName: "room123",
  member: "currentUser",
  islevel: "2",
  focusEnabled: true,
  muteOthersMic: true,
  muteOthersCamera: false,
  showAlert: (alert) => print(alert.message),
));

Implementation

Future<void> focusPanelists(FocusPanelistsOptions options) async {
  // Only hosts can focus panelists
  if (options.islevel != "2") {
    options.showAlert?.call(
      message: "Only the host can focus panelists",
      type: "danger",
      duration: 3000,
    );
    return;
  }

  options.socket.emitWithAck("focusPanelists", {
    'roomName': options.roomName,
    'focusEnabled': options.focusEnabled,
    'muteOthersMic': options.muteOthersMic,
    'muteOthersCamera': options.muteOthersCamera,
  }, ack: (response) {
    if (response == null || response['success'] != true) {
      final reason = response?['reason'] ?? 'Unknown error';
      debugPrint('focusPanelists failed: $reason');
      options.showAlert?.call(
        message: reason,
        type: "danger",
        duration: 3000,
      );
    } else if (options.focusEnabled) {
      String message = "Panelist focus enabled";
      if (options.muteOthersMic && options.muteOthersCamera) {
        message += " (others' mic & camera muted)";
      } else if (options.muteOthersMic) {
        message += " (others' mic muted)";
      } else if (options.muteOthersCamera) {
        message += " (others' camera muted)";
      }
      options.showAlert?.call(
        message: message,
        type: "success",
        duration: 3000,
      );
    }
  });
}