setClientRole method

  1. @override
Future<void> setClientRole(
  1. ClientRole role, [
  2. ClientRoleOptions? options
])

Sets the role of a user in a live interactive streaming.

You can call this method either before or after joining the channel to set the user role as audience or host. If you call this method to switch the user role after joining the channel, the SDK triggers the following callbacks:

Note

  • This method applies to the LiveBroadcasting profile only (when the profile parameter in setChannelProfile is set as LiveBroadcasting).
  • Since v3.2.1, this method can set the user level in addition to the user role.
    • The user role determines the permissions that the SDK grants to a user, such as permission to send local streams, receive remote streams, and push streams to a CDN address.
    • The user level determines the level of services that a user can enjoy within the permissions of the user's role. For example, an audience can choose to receive remote streams with low latency or ultra low latency. Levels affect prices.

Parameter role Sets the role of a user. See ClientRole.

Parameter options The detailed options of a user, including user level. See ClientRoleOptions.

Implementation

@override
Future<void> setClientRole(ClientRole role, [ClientRoleOptions? options]) {
  return _invokeMethod('setClientRole', {
    'role': ClientRoleConverter(role).value(),
    'options': options?.toJson()
  });
}