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 |
When initializing an IAgoraService
instance by calling initialize
, set the areaCode
parameter in AgoraServiceConfiguration
to specify the region for connection. The following options are available:
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
: IndiaThe following sample code shows how to specify North America as the region for connection.
// Create an IAgoraService object
auto service = createAgoraService();
agora::base::AgoraServiceConfiguration scfg;
scfg.enableAudioProcessor = true;
scfg.enableAudioDevice = false;
scfg.enableVideo = true;
scfg.useStringUid = false;
// Specify North America as the region for connection
scfg.areaCode = agora::rtc::AREA_CODE_NA;
// Initialize the IAgoraService instance
service->initialize(scfg);