switchChannel method

  1. @override
Future<void> switchChannel(
  1. String? token,
  2. String channelName, [
  3. ChannelMediaOptions? options
])

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

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(),
  });
}