To meet the laws and regulations of different countries or regions, the Agora RTC SDK supports geofencing. After enabling geofencing, the Agora SDK only connects to Agora servers within the specified region.
To meet the laws and regulations of different countries or regions, the Agora RTC SDK supports geofencing. After enabling geofencing, the SDK only connects to Agora servers within the specified region, regardless of where your app users are located.
For example, if you specify North America as the region for connection, when two users attempt to connect to Agora servers from different locations, the result is as follows:
Specified region for connection | App user location | Actual region for connection | User experience after connection 1 |
---|---|---|---|
North America | North America | North America | Normal |
China | Can be less than optimal 2 |
Before adjusting the audio volume, ensure that you have implemented the basic real-time communication functions in your project. For details, see Start a Call or Start Interactive Live Streaming.
When creating an RtcEngine instance by calling create
, set the mAreaCode
parameter in RtcEngineConfig
to specify the region for connection.
AREA_CODE_GLOB
: (Default) GlobalAREA_CODE_CN
: Mainland ChinaAREA_CODE_NA
: North AmericaAREA_CODE_EU
: EuropeAREA_CODE_AS
: Asia, excluding Mainland ChinaAREA_CODE_JP
: JapanAREA_CODE_IN
: IndiaTo specify a region for connection (such as North America) , add config.mAreaCode = AREA_CODE_NA;
before creating an instance of RtcEngine
.
// Initialize the app and join the channel.
private void initializeAndJoinChannel() {
try {
RtcEngineConfig config = new RtcEngineConfig();
config.mAppId = appId;
config.mContext = mContext;
config.mEventHandler = mEngineEventHandler.mRtcEventHandler;
// Specify the region for connection as North America.
config.mAreaCode = AREA_CODE_NA;
mRtcEngine = RtcEngine.create(config);
} catch (Exception e) {
throw new RuntimeException("Check the error.");
}
To exclude a region for connection (such as Mainland China), add config.mAreaCode = AREA_CODE_GLOB ^ AREA_CODE_CN;
before creating an instance of RtcEngine
.
// Initialize the app and join the channel.
private void initializeAndJoinChannel() {
try {
RtcEngineConfig config = new RtcEngineConfig();
config.mAppId = appId;
config.mContext = mContext;
config.mEventHandler = mEngineEventHandler.mRtcEventHandler;
// Excludes Mainland China from the regions for connection
config.mAreaCode = AREA_CODE_GLOB ^ AREA_CODE_CN;
mRtcEngine = RtcEngine.create(config);
} catch (Exception e) {
throw new RuntimeException("Check the error.");
}
This section includes links to related pages.