switchChannel method
Switches to a different channel.
This method allows the audience of a ChannelProfile.LiveBroadcasting channel to switch to a different channel. After the user successfully switches to another channel, the RtcEngineEventHandler.leaveChannel and RtcEngineEventHandler.joinChannelSuccess callbacks are triggered to indicate that the user has left the original channel and joined a new one.
Note
- This method applies to the ClientRole.Audience role in a ChannelProfile.LiveBroadcasting channel only.
Parameter token
The token for authentication. Set it as the token generated at your server. For details, see Get a token.
Parameter channelName
Unique channel name for the AgoraRTC session in the string format. The string length must be less than 64 bytes. Supported character scopes are:
- All lowercase English letters: a to z.
- All uppercase English letters: A to Z.
- All numeric characters: 0 to 9.
- The space character.
- Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",".
Parameter options
The channel media options: ChannelMediaOptions.
Implementation
@override
Future<void> switchChannel(String? token, String channelName,
[ChannelMediaOptions? options]) {
return _invokeMethod('switchChannel', {
'token': token,
'channelName': channelName,
'options': options?.toJson()
});
}