Options
All
  • Public
  • Public/Protected
  • All
Menu

Module AgoraRTM

AgoraRTM is the exported module of the Agora RTM SDK.

If you import the Agora RTM Web SDK using the <script> tag, the SDK creates a global variable called AgoraRTM, which includes all the module members.

example

Direct include <script src="agora-rtm-sdk-0.9.1.js"></script> in your HTML.

Note:

The version `0.9.1` in the file name `agora-rtm-sdk-0.9.1.js` is for reference only, please use the latest version of the SDK.

Index

Variables

Const AreaCode

AreaCode: keyof typeof AreaCode

Region for the Agora RTM service. The default is GLOBAL. See AreaCode.

Const BUILD

BUILD: string

Compilation information of the Agora RTM SDK.

example

AgoraRTM.BUILD

Const ConnectionChangeReason

ConnectionChangeReason: keyof typeof ConnectionChangeReason

The reason of the connection state change.

Const ConnectionState

ConnectionState: keyof typeof ConnectionState

The connection state.

Const END_CALL_PREFIX

END_CALL_PREFIX: string

Const LOG_FILTER_ERROR

LOG_FILTER_ERROR: LogFilterType

Output ERROR level log information.

Const LOG_FILTER_INFO

LOG_FILTER_INFO: LogFilterType

Output ERROR, WARNING, and INFO level log information.

Const LOG_FILTER_OFF

LOG_FILTER_OFF: LogFilterType

Do not output any log information.

Const LOG_FILTER_WARNING

LOG_FILTER_WARNING: LogFilterType

Output WARNING and INFO level log information.

Const LocalInvitationFailureReason

LocalInvitationFailureReason: keyof typeof LocalInvitationFailureReason

(Return to the caller) The reason of the local invitation failure.

Const LocalInvitationState

LocalInvitationState: keyof typeof LocalInvitationState

Call invitation state returned to the caller.

Const MessageType

MessageType: keyof typeof MessageType

Message type.

Const PeerOnlineState

PeerOnlineState: keyof typeof PeerOnlineState

Online state of the user.

Const PeerSubscriptionOption

PeerSubscriptionOption: keyof typeof PeerSubscriptionOption

Subscription type.

Const RemoteInvitationFailureReason

RemoteInvitationFailureReason: keyof typeof RemoteInvitationFailureReason

(Return to the callee) The reason of the local invitation failure.

Const RemoteInvitationState

RemoteInvitationState: keyof typeof RemoteInvitationState

Call invitation state returned to the callee.

Const VERSION

VERSION: string

Version of the Agora RTM SDK.

example

AgoraRTM.VERSION

Functions

createInstance

  • Creates and returns an RtmClient instance.

    The Agora RTM SDK supports creating multiple RtmClient instances.

    All methods in the RtmClient class are executed asynchronously.

    example

    Create an RtmClient instance

    import AgoraRTM from 'agora-rtm-sdk';
    const client = AgoraRTM.createInstance('demoAppId', { enableLogUpload: false }); // Pass your App ID here.

    Parameters

    • appId: string

      App ID of your project that must be a string containing 32 ASCII characters.

    • Optional config: RtmConfig

      The configuration of an RtmClient instance. See RtmConfig.

    Returns RtmClient

    An RtmClient instance.

  • deprecated

    From v2.3.2. Use createInstance instead.

    Creates and returns an RtmClient instance.

    The Agora RTM SDK supports creating multiple RtmClient instances.

    All methods in the RtmClient class are executed asynchronously.

    example

    Create an RtmClient instance

    import AgoraRTM from 'agora-rtm-sdk';
    const client = AgoraRTM.createInstance('demoAppId', { enableLogUpload: false }); // Pass your App ID here.

    Parameters

    • appId: string

      App ID of your project that must be a string containing 32 ASCII characters.

    • Optional config: RtmConfig

      The configuration of an RtmClient instance. See RtmConfig.

    • Optional areaCodes: AreaCode[]

      Region for the Agora RTM service. See AreaCode.

    Returns RtmClient

    An RtmClient instance.

setArea

  • setArea(areaConfig: object): void
  • since

    1.4.3

    Sets the regions for connection.

    Note:

    • This advanced feature applies to scenarios that have regional restrictions.
    • By default, the SDK connects to nearby Agora servers. After specifying the regions, the SDK connects to the Agora servers within those regions.
    • You can remove some areas from the region for connection.

    Parameters

    • areaConfig: object

      The configration of regions for connection.

      • areaCodes: The region for connection. For details, see AreaCode.
      • excludedArea: Exclude areas, which can be set to CHINA, JAPAN and ASIA. This parameter is only valid when the region for connection is GLOBAL.

    Returns void