joinChannelWithUserAccountEx abstract method
- required String token,
- required String channelId,
- required String userAccount,
- required ChannelMediaOptions options,
Join a channel using a user account and token, and set the media options.
Before calling this method, if you have not called registerLocalUserAccount to register a user account, when you call this method to join a channel, the SDK automatically creates a user account for you. Calling the registerLocalUserAccount method to register a user account, and then calling this method to join a channel can shorten the time it takes to enter the channel. Once a user joins the channel, the user subscribes to the audio and video streams of all the other users in the channel by default, giving rise to usage and billings. If you want to stop subscribing to the media stream of other users, you can set the options parameter or call the corresponding mute method. To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a UID, then ensure all the other users use the UID too. The same applies to the user account. If a user joins the channel with the Agora Web SDK, ensure that the ID of the user is set to the same parameter type.
token
The token generated on your server for authentication. (Recommended) If your project has enabled the security mode (using APP ID and Token for authentication), this parameter is required. If you have only enabled the testing mode (using APP ID for authentication), this parameter is optional. You will automatically exit the channel 24 hours after successfully joining in. If you need to join different channels at the same time or switch between channels, Agora recommends using a wildcard token so that you don't need to apply for a new token every time joining a channel.channelId
The channel name. This parameter signifies the channel in which users engage in real-time audio and video interaction. Under the premise of the same App ID, users who fill in the same channel ID enter the same channel for audio and video interaction. The string length must be less than 64 bytes. Supported characters (89 characters in total): All lowercase English letters: a to z. All uppercase English letters: A to Z. All numeric characters: 0 to 9. "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "", "
", "^", "_", "{", "}", "|", "~", ","userAccount
The user account. This parameter is used to identify the user in the channel for real-time audio and video engagement. You need to set and manage user accounts yourself and ensure that each user account in the same channel is unique. The maximum length of this parameter is 255 bytes. Ensure that you set this parameter and do not set it as NULL. Supported characters are as follows(89 in total): The 26 lowercase English letters: a to z. The 26 uppercase English letters: A to Z. All numeric characters: 0 to 9. Space "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "", "
", "^", "_", "{", "}", "|", "~", ","options
The channel media options. See ChannelMediaOptions.
Returns When the method call succeeds, there is no return value; when fails, the AgoraRtcException exception is thrown. You need to catch the exception and handle it accordingly. < 0: Failure. -2: The parameter is invalid. For example, the token is invalid, the uid parameter is not set to an integer, or the value of a member in ChannelMediaOptions is invalid. You need to pass in a valid parameter and join the channel again. -3: Fails to initialize the RtcEngine object. You need to reinitialize the RtcEngine object. -7: The RtcEngine object has not been initialized. You need to initialize the RtcEngine object before calling this method. -8: The internal state of the RtcEngine object is wrong. The typical cause is that after calling startEchoTest to start a call loop test, you call this method to join the channel without calling stopEchoTest to stop the test. You need to call stopEchoTest before calling this method. -17: The request to join the channel is rejected. The typical cause is that the user is already in the channel. Agora recommends that you use the onConnectionStateChanged callback to see whether the user is in the channel. Do not call this method to join the channel unless you receive the connectionStateDisconnected (1) state. -102: The channel name is invalid. You need to pass in a valid channel name in channelId to rejoin the channel. -121: The user ID is invalid. You need to pass in a valid user ID in uid to rejoin the channel.
Implementation
Future<void> joinChannelWithUserAccountEx(
{required String token,
required String channelId,
required String userAccount,
required ChannelMediaOptions options});