io.agora.rtc

## Class AgoraRtcConn

- java.lang.Object
- - io.agora.rtc.AgoraRtcConn

-     public class AgoraRtcConn
      extends java.lang.Object

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private AgoraParameter` | `agoraParameter`
    `private long` | `cptr`
    `private INetworkObserver` | `networkObserver`
    `private IRtcConnObserver` | `rtcConnObserver`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AgoraRtcConn(long cptr)` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `connect(java.lang.String token, java.lang.String channelId, java.lang.String userId)` Connects to a channel
    `int` | `createDataStream(Out streamId, int reliable, int ordered)` Creates data stream
    `void` | `destroy()` Destroys the RtcConnection instance
    `void` | `destroyConnInfo(RtcConnInfo info)` Destroys connection information object
    `void` | `destroyTransportStats(RtcStats stats)` Destroys transport statistics object
    `void` | `destroyUserInfo(UserInfo info)` Destroys user information object
    `int` | `disconnect()` Disconnects from current channel
    `int` | `enableEncryption(int enabled, EncryptionConfig config)` Enables/disables encryption
    `AgoraParameter` | `getAgoraParameter()` Gets Agora parameter object
    `int` | `getConnId()` Gets connection ID
    `RtcConnInfo` | `getConnInfo()` Gets connection information
    `AgoraLocalUser` | `getLocalUser()` Gets local user object
    `RtcStats` | `getTransportStats()` Gets transport statistics
    `UserInfo` | `getUserInfo(java.lang.String userId)` Gets user information by user ID
    `AccountInfo` | `getUserInfoByUid(java.lang.String userId)` Gets user information by UID
    `AccountInfo` | `getUserInfoByUserAccount(java.lang.String userAccount)` Gets user information by user account
    `private int` | `nativeConnect(long cptr, java.lang.String token, java.lang.String channelId, java.lang.String userId)`
    `private int` | `nativeCreateDataStream(long cptr, Out streamId, int reliable, int ordered)`
    `private void` | `nativeDestroy(long cptr)`
    `private void` | `nativeDestroyConnInfo(long cptr, RtcConnInfo info)`
    `private void` | `nativeDestroyTransportStats(long cptr, RtcStats stats)`
    `private void` | `nativeDestroyUserInfo(long cptr, UserInfo info)`
    `private int` | `nativeDisconnect(long cptr)`
    `private int` | `nativeEnableEncryption(long cptr, int enabled, EncryptionConfig config)`
    `private AgoraParameter` | `nativeGetAgoraParameter(long cptr)`
    `private int` | `nativeGetConnId(long cptr)`
    `private RtcConnInfo` | `nativeGetConnInfo(long cptr)`
    `private AgoraLocalUser` | `nativeGetLocalUser(long cptr)`
    `private RtcStats` | `nativeGetTransportStats(long cptr)`
    `private UserInfo` | `nativeGetUserInfo(long cptr, java.lang.String userId)`
    `private AccountInfo` | `nativeGetUserInfoByUid(long cptr, java.lang.String userId)`
    `private AccountInfo` | `nativeGetUserInfoByUserAccount(long cptr, java.lang.String userAccount)`
    `private int` | `nativeRegisterNetworkObserver(long cptr, INetworkObserver observer)`
    `private int` | `nativeRegisterObserver(long cptr, IRtcConnObserver observer)`
    `private int` | `nativeRenewToken(long cptr, java.lang.String token)`
    `private int` | `nativeSendCustomReportMessage(long cptr, java.lang.String id, java.lang.String category, java.lang.String event, java.lang.String label, int value)`
    `private int` | `nativeSendStreamMessage(long cptr, int streamId, byte[] messageData)`
    `private int` | `nativeStartLastmileProbeTest(long cptr, LastmileProbeConfig config)`
    `private int` | `nativeStopLastmileProbeTest(long cptr)`
    `private int` | `nativeUnregisterNetworkObserver(long cptr)`
    `private int` | `nativeUnregisterObserver(long cptr)`
    `int` | `registerNetworkObserver(INetworkObserver observer)` Registers a network observer
    `int` | `registerObserver(IRtcConnObserver observer)` Registers an RTC connection observer
    `int` | `renewToken(java.lang.String token)` Renews the token
    `int` | `sendCustomReportMessage(java.lang.String id, java.lang.String category, java.lang.String event, java.lang.String label, int value)` Sends custom report message
    `int` | `sendStreamMessage(int streamId, byte[] messageData)` Sends data stream message
    `int` | `sendStreamMessage(int streamId, java.lang.String message, int length)` Deprecated. This method is not recommended. Use sendStreamMessage(int streamId, byte[] messageData) instead. Send string message through data stream
    `int` | `startLastmileProbeTest(LastmileProbeConfig config)` Starts last-mile network probe test
    `int` | `stopLastmileProbeTest()` Stops last-mile network probe test
    `int` | `unregisterNetworkObserver()` Unregisters the network observer
    `int` | `unregisterObserver()` Unregisters the RTC connection observer

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### cptr

          private long cptr

    - #### rtcConnObserver

          private IRtcConnObserver rtcConnObserver

    - #### networkObserver

          private INetworkObserver networkObserver

    - #### agoraParameter

          private AgoraParameter agoraParameter

  - ### Constructor Detail

    - #### AgoraRtcConn

          public AgoraRtcConn(long cptr)

      Constructor
      Parameters:
        `cptr` - Native pointer

  - ### Method Detail

    - #### destroy

          public void destroy()

      Destroys the RtcConnection instance

    - #### registerObserver

          public int registerObserver(IRtcConnObserver observer)

      Registers an RTC connection observer
      Parameters:
        `observer` - The observer to register
      Returns:
        0: Success, < 0: Failure

    - #### unregisterObserver

          public int unregisterObserver()

      Unregisters the RTC connection observer
      Returns:
        0: Success, < 0: Failure

    - #### registerNetworkObserver

          public int registerNetworkObserver(INetworkObserver observer)

      Registers a network observer
      Parameters:
        `observer` - The observer to register
      Returns:
        0: Success, < 0: Failure

    - #### unregisterNetworkObserver

          public int unregisterNetworkObserver()

      Unregisters the network observer
      Returns:
        0: Success, < 0: Failure

    - #### sendStreamMessage

          @Deprecated
          public int sendStreamMessage(int streamId,
                                                   java.lang.String message,
                                                   int length)

      Deprecated. This method is not recommended. Use sendStreamMessage(int streamId, byte[] messageData) instead. Send string message through data stream
      Parameters:
        `streamId` - ID of the sent data stream
        `message` - Message content
        `length` - Message length
      Returns:
        0: Success, < 0: Failure

    - #### sendStreamMessage

          public int sendStreamMessage(int streamId,
                                       byte[] messageData)

      Sends data stream message
      Parameters:
        `streamId` - ID of the data stream
        `messageData` - Message content in bytes
      Returns:
        0: Success, < 0: Failure

    - #### connect

          public int connect(java.lang.String token,
                             java.lang.String channelId,
                             java.lang.String userId)

      Connects to a channel
      Parameters:
        `token` - Authentication token
        `channelId` - Channel ID to join
        `userId` - User ID
      Returns:
        0: Success, < 0: Failure

    - #### disconnect

          public int disconnect()

      Disconnects from current channel
      Returns:
        0: Success, < 0: Failure

    - #### startLastmileProbeTest

          public int startLastmileProbeTest(LastmileProbeConfig config)

      Starts last-mile network probe test
      Parameters:
        `config` - Configuration for the probe test
      Returns:
        0: Success, < 0: Failure

    - #### stopLastmileProbeTest

          public int stopLastmileProbeTest()

      Stops last-mile network probe test
      Returns:
        0: Success, < 0: Failure

    - #### renewToken

          public int renewToken(java.lang.String token)

      Renews the token
      Parameters:
        `token` - New token to use
      Returns:
        0: Success, < 0: Failure

    - #### getConnInfo

          public RtcConnInfo getConnInfo()

      Gets connection information
      Returns:
        RtcConnInfo object containing connection details

    - #### destroyConnInfo

          public void destroyConnInfo(RtcConnInfo info)

      Destroys connection information object
      Parameters:
        `info` - RtcConnInfo object to destroy

    - #### getLocalUser

          public AgoraLocalUser getLocalUser()

      Gets local user object
      Returns:
        AgoraLocalUser object

    - #### getUserInfo

          public UserInfo getUserInfo(java.lang.String userId)

      Gets user information by user ID
      Parameters:
        `userId` - User ID to query
      Returns:
        UserInfo object containing user details

    - #### getUserInfoByUserAccount

          public AccountInfo getUserInfoByUserAccount(java.lang.String userAccount)

      Gets user information by user account
      Parameters:
        `userAccount` - User account to query
      Returns:
        AccountInfo object containing user details

    - #### getUserInfoByUid

          public AccountInfo getUserInfoByUid(java.lang.String userId)

      Gets user information by UID
      Parameters:
        `userId` - User ID to query
      Returns:
        AccountInfo object containing user details

    - #### destroyUserInfo

          public void destroyUserInfo(UserInfo info)

      Destroys user information object
      Parameters:
        `info` - UserInfo object to destroy

    - #### getConnId

          public int getConnId()

      Gets connection ID
      Returns:
        Connection ID

    - #### getTransportStats

          public RtcStats getTransportStats()

      Gets transport statistics
      Returns:
        RtcStats object containing transport statistics

    - #### destroyTransportStats

          public void destroyTransportStats(RtcStats stats)

      Destroys transport statistics object
      Parameters:
        `stats` - RtcStats object to destroy

    - #### getAgoraParameter

          public AgoraParameter getAgoraParameter()

      Gets Agora parameter object
      Returns:
        AgoraParameter object

    - #### createDataStream

          public int createDataStream(Out streamId,
                                      int reliable,
                                      int ordered)

      Creates data stream
      Parameters:
        `streamId` - Output parameter to receive stream ID
        `reliable` - Whether the stream is reliable
        `ordered` - Whether the stream is ordered
      Returns:
        0: Success, < 0: Failure

    - #### enableEncryption

          public int enableEncryption(int enabled,
                                      EncryptionConfig config)

      Enables/disables encryption
      Parameters:
        `enabled` - Whether to enable encryption (1: Enable, 0: Disable)
        `config` - Encryption configuration
      Returns:
        0: Success, < 0: Failure

    - #### sendCustomReportMessage

          public int sendCustomReportMessage(java.lang.String id,
                                             java.lang.String category,
                                             java.lang.String event,
                                             java.lang.String label,
                                             int value)

      Sends custom report message
      Parameters:
        `id` - Report ID
        `category` - Report category
        `event` - Report event
        `label` - Report label
        `value` - Report value
      Returns:
        0: Success, < 0: Failure

    - #### nativeDestroy

          private void nativeDestroy(long cptr)

    - #### nativeRegisterObserver

          private int nativeRegisterObserver(long cptr,
                                             IRtcConnObserver observer)

    - #### nativeUnregisterObserver

          private int nativeUnregisterObserver(long cptr)

    - #### nativeRegisterNetworkObserver

          private int nativeRegisterNetworkObserver(long cptr,
                                                    INetworkObserver observer)

    - #### nativeUnregisterNetworkObserver

          private int nativeUnregisterNetworkObserver(long cptr)

    - #### nativeSendStreamMessage

          private int nativeSendStreamMessage(long cptr,
                                              int streamId,
                                              byte[] messageData)

    - #### nativeConnect

          private int nativeConnect(long cptr,
                                    java.lang.String token,
                                    java.lang.String channelId,
                                    java.lang.String userId)

    - #### nativeDisconnect

          private int nativeDisconnect(long cptr)

    - #### nativeStartLastmileProbeTest

          private int nativeStartLastmileProbeTest(long cptr,
                                                   LastmileProbeConfig config)

    - #### nativeStopLastmileProbeTest

          private int nativeStopLastmileProbeTest(long cptr)

    - #### nativeRenewToken

          private int nativeRenewToken(long cptr,
                                       java.lang.String token)

    - #### nativeGetConnInfo

          private RtcConnInfo nativeGetConnInfo(long cptr)

    - #### nativeDestroyConnInfo

          private void nativeDestroyConnInfo(long cptr,
                                             RtcConnInfo info)

    - #### nativeGetLocalUser

          private AgoraLocalUser nativeGetLocalUser(long cptr)

    - #### nativeGetUserInfo

          private UserInfo nativeGetUserInfo(long cptr,
                                             java.lang.String userId)

    - #### nativeGetUserInfoByUserAccount

          private AccountInfo nativeGetUserInfoByUserAccount(long cptr,
                                                             java.lang.String userAccount)

    - #### nativeGetUserInfoByUid

          private AccountInfo nativeGetUserInfoByUid(long cptr,
                                                     java.lang.String userId)

    - #### nativeDestroyUserInfo

          private void nativeDestroyUserInfo(long cptr,
                                             UserInfo info)

    - #### nativeGetConnId

          private int nativeGetConnId(long cptr)

    - #### nativeGetTransportStats

          private RtcStats nativeGetTransportStats(long cptr)

    - #### nativeDestroyTransportStats

          private void nativeDestroyTransportStats(long cptr,
                                                   RtcStats stats)

    - #### nativeGetAgoraParameter

          private AgoraParameter nativeGetAgoraParameter(long cptr)

    - #### nativeCreateDataStream

          private int nativeCreateDataStream(long cptr,
                                             Out streamId,
                                             int reliable,
                                             int ordered)

    - #### nativeEnableEncryption

          private int nativeEnableEncryption(long cptr,
                                             int enabled,
                                             EncryptionConfig config)

    - #### nativeSendCustomReportMessage

          private int nativeSendCustomReportMessage(long cptr,
                                                    java.lang.String id,
                                                    java.lang.String category,
                                                    java.lang.String event,
                                                    java.lang.String label,
                                                    int value)