joinChannel method

  1. @override
Future<void> joinChannel(
  1. String? token,
  2. String? channelName,
  3. String? optionalUid
)

Allows a user to join a channel.

Users in the same channel can talk to each other, and multiple users in the same channel can start a group chat. Users with different App IDs cannot call each other. You must call the RtcEngine.leaveChannel method to exit the current call before joining another channel. A successful joinChannel method call triggers the following callbacks:

When the connection between the client and server is interrupted due to poor network conditions, the SDK tries reconnecting to the server. When the local client successfully rejoins the channel, the SDK triggers the RtcEngineEventHandler.rejoinChannelSuccess callback on the local client.

Note

  • A channel does not accept duplicate uids, such as two users with the same uid. If you set uid as 0, the system automatically assigns a uid.

Warning

  • Ensure that the App ID used for creating the token is the same App ID used in the create method for creating an RtcEngine object. Otherwise, CDN live streaming may fail.

Parameter token token Parameter channelName The unique channel name for the arRTC 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 optionalUid (Optional) User ID. optionalUid must be unique. If optionalUid is not assigned (or set to 0), the SDK assigns and returns uid in the RtcEngineEventHandler.joinChannelSuccess callback. Your app must record and maintain the returned uid since the SDK does not do so.

Implementation

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