|
| AgoraRtcConn (long cptr) |
|
void | destroy () |
|
native int | connect (String token, String chan_id, String user_id) |
|
native int | disconnect () |
|
native int | startLastmileProbeTest (LastmileProbeConfig config) |
|
native int | stopLastmileProbeTest () |
|
native int | renewToken (String token) |
|
native RtcConnInfo | getConnInfo () |
|
native void | destroyConnInfo (RtcConnInfo info) |
|
native AgoraLocalUser | getLocalUser () |
|
native UserInfo | getUserInfo (String user_id) |
|
native void | destroyUserInfo (UserInfo info) |
|
native int | registerObserver (IRtcConnObserver observer) |
|
native int | unregisterObserver () |
|
native int | registerNetworkObserver (INetworkObserver observer) |
|
native int | unregisterNetworkObserver () |
|
native int | getConnId () |
|
native RtcStats | getTransportStats () |
|
native void | destroyTransportStats (RtcStats stats) |
|
native AgoraParameter | getAgoraParameter () |
|
native int | createDataStream (Out stream_id, int reliable, int ordered) |
|
native int | sendStreamMessage (int stream_id, String data, int length) |
|
native int | enableEncryption (int enabled, EncryptionConfig config) |
|
native int | sendCustomReportMessage (String id, String category, String event, String label, int value) |
|
The AgoraRtcConn
class.
You can use this class for managing the connection between your app and an Agora RTC 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 to the connection states or events through IRtcConnObserver
. AgoraRtcConn
also monitors remote users in the channel. The SDK notifies your app when a remote user joins or leaves the channel.
native int io.agora.rtc.AgoraRtcConn.connect |
( |
String |
token, |
|
|
String |
chan_id, |
|
|
String |
user_id |
|
) |
| |
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 app ID. |
chan_id | 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: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ","
|
user_id | The ID of the local user. If you do not specify a user ID or set this parameter as null , the SDK returns a user ID in the onConnected callback. Your app must record and maintain the ID since the SDK does not do so. |
- Returns
- 0: Success.
- < 0: Failure.
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.