|
virtual int | connect (const char *token, const char *channelId, user_id_t userId)=0 |
|
virtual int | disconnect ()=0 |
|
virtual int | startLastmileProbeTest (const LastmileProbeConfig &config)=0 |
|
virtual int | stopLastmileProbeTest ()=0 |
|
virtual int | renewToken (const char *token)=0 |
|
virtual TConnectionInfo | getConnectionInfo ()=0 |
|
virtual ILocalUser * | getLocalUser ()=0 |
|
virtual int | getRemoteUsers (UserList &users)=0 |
|
virtual int | getUserInfo (user_id_t userId, agora::UserInfo &userInfo)=0 |
|
virtual int | registerObserver (IRtcConnectionObserver *observer, void(*safeDeleter)(IRtcConnectionObserver *)=NULL)=0 |
|
virtual int | unregisterObserver (IRtcConnectionObserver *observer)=0 |
|
virtual int | registerNetworkObserver (INetworkObserver *observer, void(*safeDeleter)(INetworkObserver *)=NULL)=0 |
|
virtual int | unregisterNetworkObserver (INetworkObserver *observer)=0 |
|
virtual conn_id_t | getConnId ()=0 |
|
virtual RtcStats | getTransportStats ()=0 |
|
virtual agora::base::IAgoraParameter * | getAgoraParameter ()=0 |
|
virtual int | createDataStream (int *streamId, bool reliable, bool ordered, bool sync)=0 |
|
virtual int | sendStreamMessage (int streamId, const char *data, size_t length)=0 |
|
virtual int | enableEncryption (bool enabled, const EncryptionConfig &config)=0 |
|
virtual int | getUserInfoByUserAccount (const char *userAccount, rtc::UserInfo *userInfo)=0 |
|
virtual int | getUserInfoByUid (uid_t uid, rtc::UserInfo *userInfo)=0 |
|
The IRtcConnection
class.
You can use this class for managing the connection between your app and an Agora Channel.
Once connected, your app gets an AgoraLocalUser
object for publishing and subscribing to media streams in the Agora Channel.
Connecting to a channel is done asynchronously, and your app can listen for the connection states or events through IRtcConnectionObserver
. IRtcConnection
also monitors remote users in the channel. The SDK notifies your app when a remote user joins or leaves the channel.
virtual int agora::rtc::IRtcConnection::connect |
( |
const char * |
token, |
|
|
const char * |
channelId, |
|
|
user_id_t |
userId |
|
) |
| |
|
pure virtual |
Connects to an Agora channel.
When the method call succeeds, the connection state changes from CONNECTION_STATE_DISCONNECTED(1)
to CONNECTION_STATE_CONNECTING(2)
.
Depending on the whether the connection succeeds or not, the connection state changes to either CONNECTION_STATE_CONNECTED(3)
or CONNECTION_STATE_FAILED(5)
. The SDK also triggers onConnected
or onDisconnected
to notify you of the state change.
- Parameters
-
token | The RTC token. See Authenticate Your Users with Tokens. |
channelId | The channel name. It must be in the string format and not exceed 64 bytes in length. 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: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ","
|
userId | The ID of the local user. If you do not specify a user ID or set userId as null , the SDK returns a user ID in the onConnected callback. Your app must record and maintain the userId since the SDK does not do so. |
- Returns
- 0: Success.
- < 0: Failure.
- -2(ERR_INVALID_ARGUMENT): The argument that you pass is invalid.
- -8(ERR_INVALID_STATE): The current connection state is not CONNECTION_STATE_DISCONNECTED(1).
virtual int agora::rtc::IRtcConnection::enableEncryption |
( |
bool |
enabled, |
|
|
const EncryptionConfig & |
config |
|
) |
| |
|
pure virtual |
Enables/Disables the built-in encryption.
In scenarios requiring high security, Agora recommends calling this method to enable the built-in encryption before joining a channel.
All users in the same channel must use the same encryption mode and encryption key. Once all users leave the channel, the encryption key of this channel is automatically cleared.
- Note
- If you enable the built-in encryption, you cannot use the RTMP streaming function.
- Parameters
-
enabled | Whether to enable the built-in encryption:
- true: Enable the built-in encryption.
- false: Disable the built-in encryption.
|
config | Configurations of built-in encryption schemas. See EncryptionConfig. |
- Returns
- 0: Success.
- < 0: Failure.
virtual int agora::rtc::IRtcConnection::startLastmileProbeTest |
( |
const LastmileProbeConfig & |
config | ) |
|
|
pure virtual |
Starts the last-mile network probe test.
Call this method before connecting to the channel to get the uplink and downlink last-mile network statistics, including the bandwidth, packet loss, jitter, and round-trip time (RTT).
After you enable the last-mile network probe test, the SDK triggers the following callbacks:
- onLastmileQuality: The SDK triggers this callback within two seconds depending on the network conditions. This callback rates the network conditions and is more closely linked to the user experience.
- onLastmileProbeResult: The SDK triggers this callback within 30 seconds depending on the network conditions. This callback reports the real-time statistics of the network conditions and is more objective.
- Note
- Do not call any other method before receiving the onLastmileQuality and onLastmileProbeResult callbacks. Otherwise, the callbacks may be interrupted.
- In the live-broadcast profile, a host should not call this method after connecting to a channel.
- Parameters
-
- Returns
- 0: Success.
- < 0: Failure.