setClientRole method
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:
- The local client: RtcChannelEventHandler.clientRoleChanged.
- The remote client: RtcChannelEventHandler.userJoined or RtcChannelEventHandler.userOffline (UserOfflineReason.BecomeAudience).
Note
- This method applies to the
LiveBroadcasting
profile only (when theprofile
parameter insetChannelProfile
is set asLiveBroadcasting
). - 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
The role of the 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()
});
}