switchChannel method

  1. @override
Future<void> switchChannel(
  1. String token,
  2. String channelName
)

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:

  • In situations not requiring high security: You can use the temporary token generated at Console. For details, see Get a temporary token.
  • In situations requiring high security: Set it as the token generated at your server. For details, see Get a token.

Parameter channelName Unique channel name for the MetaRTC 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: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "", "", "^", "_", " {", "}", "|", "~", ",".

Implementation

@override
Future<void> switchChannel(String token, String channelName) {
  return _invokeMethod(
      'switchChannel', {'token': token, 'channelName': channelName});
}