updateRole method

void updateRole(
  1. Map<String, dynamic> data
)

Update the role of the Remote Peer in the Room, this will emit an event updated with the updated role.

Implementation

void updateRole(Map<String, dynamic> data) {
  if (!checkPermission(permissionTypeCheck: PermissionType.admin)) {
    return;
  }

  try {
    logger.i('🔔 Updating Peer Role | data -> $data');

    if (data['role'] == _role) {
      logger.w('🔔 Role is already set to ${data['role']}');
      return;
    }

    LocalPeer localPeer = LocalPeer.getInstance();
    Socket socket = localPeer.socket;

    socket.publish(Request_Request.updatePeerRole, {
      'peerId': peerId,
      'role': data['role'],
    });
  } catch (error) {
    logger.e('🔔 Error Updating Role | Error -> $error');
  }
}