updatePanelists function
Updates the entire panelist list. Only hosts (islevel === "2") can update panelists.
Example:
await updatePanelists(UpdatePanelistsOptions(
socket: socket,
panelists: [participant1, participant2],
roomName: "room123",
member: "currentUser",
islevel: "2",
showAlert: (alert) => print(alert.message),
));
Implementation
Future<void> updatePanelists(UpdatePanelistsOptions options) async {
// Only hosts can update panelists
if (options.islevel != "2") {
options.showAlert?.call(
message: "Only the host can update panelists",
type: "danger",
duration: 3000,
);
return;
}
options.socket.emitWithAck("updatePanelists", {
'panelists': options.panelists
.map((p) => {
'id': p.id,
'name': p.name,
})
.toList(),
'roomName': options.roomName,
}, ack: (response) {
if (response == null || response['success'] != true) {
final reason = response?['reason'] ?? 'Unknown error';
debugPrint('updatePanelists failed: $reason');
options.showAlert?.call(
message: reason,
type: "danger",
duration: 3000,
);
}
});
}