|
Agora Server Gateway SDK C++ API Reference
|
#include <NGIAgoraRtcConnection.h>
Public Member Functions | |
| 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 |
Protected Member Functions | |
| ~IRtcConnection () | |
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 ILocalUser 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.
|
inlineprotected |
|
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.
| token | The RTC token. See Authenticate Your Users with Tokens. If your project does not enable the app certificate, you need only to enter the App ID of your Agora project. |
| channelId | The channel name. It must be in the string format and not exceed 64 bytes in length. Supported character scopes are:
|
| 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. |
|
pure virtual |
Creates a data stream.
Each user can create up to five data streams in a single channel.
reliable as true and ordered as false.ordered parameter as true if you need the receiver to receive the data packet immediately.sync parameter as true if you need the receiver to receive the data packet immediately. Agora recommends that you set the sync parameter to true only when you need to implement specific functions, for example, lyric synchronization.| streamId | Output parameter. A pointer to the ID of the created data stream. |
| reliable | Whether or not the data stream is reliable:
|
| ordered | Whether or not the recipients receive the data stream in the sent order:
|
| sync | Whether to synchronize the data packet with the published audio packet.
|
|
pure virtual |
Disconnects from the Agora channel.
Once your app successful disconnects from the channel, the connection state changes to CONNECTION_STATE_DISCONNECTED(1). You are also notified with the callback onDisconnected.
|
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.
| enabled | Whether to enable the built-in encryption:
|
| config | Configurations of built-in encryption schemas. See EncryptionConfig. |
|
pure virtual |
Gets the IAgoraParameter object for a connection.
The IAgoraParameter object obtained through this method is only effective for the current connection. For global settings, call the IAgoraService::getAgoraParameter method.
IAgoraParameter object: Success.
|
pure virtual |
Gets the connection information.
|
pure virtual |
Gets the ID of the connection.
|
pure virtual |
Gets the ILocalUser object.
|
pure virtual |
Gets the information of all the remote users in the channel.
After a user successfully connects to the channel, you can also get the information of this remote user with the onUserJoined callback.
| [out] | users | The reference to the UserList object, which contains the information of all users in the channel. |
|
pure virtual |
Gets the transportation statistics of the RTC connection.
|
pure virtual |
Gets the information of a specified remote user in the channel.
| [in] | userId | ID of the user whose information you want to get. |
| [out] | userInfo | The reference to the UserInfo object, which contains the information of the specified user. |
|
pure virtual |
Gets the user information by user ID, which is in integer format.
| uid | The ID of the remote user. | |
| [in,out] | userInfo | A UserInfo object that identifies the user:
|
|
pure virtual |
Gets the user information by user account, which is in string format.
| userAccount | The user account of the user. | |
| [in,out] | userInfo | A UserInfo object that identifies the user:
|
|
pure virtual |
Registers an network observer object.
| observer | The pointer to the INetworkObserver object. |
|
pure virtual |
Registers an RTC connection observer. You can call this method only after creating an IRtcConnection object.
| observer | The pointer to the IRtcConnectionObserver object. |
|
pure virtual |
Renews the token.
The token expires after a certain period of time.
When the onTokenPrivilegeWillExpire callback reports ERR_TOKEN_EXPIRED(109), you must generate a new token from the server and then call this method to renew it. Otherwise, the SDK disconnects from the Agora RTC channel.
| token | The pointer to the new token. |
|
pure virtual |
Sends data stream messages.
Sends data stream messages to all users in a channel. The SDK has the following restrictions on this method:
A successful method call triggers the onStreamMessage callback on the remote client, from which the remote user gets the stream message.
| streamId | The data stream ID. You can get the data stream ID by calling createDataStream. |
| data | The message to be sent. |
| length | The length of the data. |
|
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:
| config | The configurations of the last-mile network probe test. See LastmileProbeConfig. |
|
pure virtual |
Stops the last-mile network probe test.
|
pure virtual |
Releases the registered INetworkObserver object.
| observer | The pointer to the INetworkObserver object created by the registerNetworkObserver method. |
|
pure virtual |
Releases the registered IRtcConnectionObserver object.
| observer | The pointer to the IRtcConnectionObserver object created by the registerObserver method. |