Agora Server Gateway SDK Java API Reference
|
Public Member Functions | |
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.
io.agora.rtc.AgoraRtcConn.AgoraRtcConn | ( | long | cptr | ) |
Constructor.
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.
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:
|
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. |
native int io.agora.rtc.AgoraRtcConn.createDataStream | ( | Out | stream_id, |
int | reliable, | ||
int | ordered | ||
) |
Creates a data stream.
Each user can create up to five data streams in a single channel.
reliable
as 1
and ordered
as 0
.ordered
parameter as 0
if you need the receiver to receive the data packet immediately.stream_id | 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:
|
void io.agora.rtc.AgoraRtcConn.destroy | ( | ) |
Destructor.
native void io.agora.rtc.AgoraRtcConn.destroyConnInfo | ( | RtcConnInfo | info | ) |
native void io.agora.rtc.AgoraRtcConn.destroyTransportStats | ( | RtcStats | stats | ) |
native void io.agora.rtc.AgoraRtcConn.destroyUserInfo | ( | UserInfo | info | ) |
native int io.agora.rtc.AgoraRtcConn.disconnect | ( | ) |
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.
native int io.agora.rtc.AgoraRtcConn.enableEncryption | ( | int | enabled, |
EncryptionConfig | config | ||
) |
Enables/Disables the built-in encryption.
In scenarios requiring high security, Agora recommends calling enableEncryption
to enable the built-in encryption for a connection before connecting to a channel.
enabled | Whether to enable the built-in encryption.
|
config | Configurations of built-in encryption schemas. See EncryptionConfig. |
native AgoraParameter io.agora.rtc.AgoraRtcConn.getAgoraParameter | ( | ) |
Gets the AgoraParameter object for a connection.
The AgoraParameter
object obtained through this method is only effective for the current connection. For global settings, call the AgoraService.getAgoraParameter method.
AgoraParameter
object: Success.null
: Failure. native int io.agora.rtc.AgoraRtcConn.getConnId | ( | ) |
Gets the ID of the connection.
native RtcConnInfo io.agora.rtc.AgoraRtcConn.getConnInfo | ( | ) |
Gets the connection information.
native AgoraLocalUser io.agora.rtc.AgoraRtcConn.getLocalUser | ( | ) |
Gets the AgoraLocalUser object.
native RtcStats io.agora.rtc.AgoraRtcConn.getTransportStats | ( | ) |
Gets the transportation statistics of the RTC connection.
native UserInfo io.agora.rtc.AgoraRtcConn.getUserInfo | ( | String | user_id | ) |
Gets the information of a specified remote user in the channel.
user_id | ID of the user whose information you want to get. |
native int io.agora.rtc.AgoraRtcConn.registerNetworkObserver | ( | INetworkObserver | observer | ) |
Registers an network observer object.
observer | The INetworkObserver object. |
native int io.agora.rtc.AgoraRtcConn.registerObserver | ( | IRtcConnObserver | observer | ) |
Registers an RTC connection observer. You can call this method only after creating an IRtcConnection
object.
observer | The IRtcConnObserver object. |
native int io.agora.rtc.AgoraRtcConn.renewToken | ( | String | token | ) |
Renews the token.
The token expires after a certain period of time. When the onTokenPrivilegeWillExpire callback is triggered, you must generate a new token from the server and then call this method to renew it. Otherwise, the SDK disconnects from the Agora channel.
token | The new token. |
native int io.agora.rtc.AgoraRtcConn.sendCustomReportMessage | ( | String | id, |
String | category, | ||
String | event, | ||
String | label, | ||
int | value | ||
) |
Reports a custom event to Agora.
id | The custom event ID. |
category | The category of the custom event. |
event | The custom event to report. |
label | The label of the custom event. |
value | The value of the custom event. |
native int io.agora.rtc.AgoraRtcConn.sendStreamMessage | ( | int | stream_id, |
String | data, | ||
int | length | ||
) |
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.
stream_id | 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. |
native int io.agora.rtc.AgoraRtcConn.startLastmileProbeTest | ( | LastmileProbeConfig | config | ) |
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. |
native int io.agora.rtc.AgoraRtcConn.stopLastmileProbeTest | ( | ) |
Stops the last-mile network probe test.
native int io.agora.rtc.AgoraRtcConn.unregisterNetworkObserver | ( | ) |
Releases the registered INetworkObserver
object.
native int io.agora.rtc.AgoraRtcConn.unregisterObserver | ( | ) |
Releases the registered IRtcConnObserver
object.