跳到主要内容

WebSDK初始化

更新时间:2025-12-05 19:32:15

SDK初始化


/**
* 初始化SDK
* @param config - 初始配置项
* @returns
* @public
*/
declare function init(config: InitConfig): Promise<void>;

/**
* SDK实始化配置选择
* @public
*/
declare class InitConfig {
/**
* 是否开启日志调试
*/
debug: boolean;
/**
* 通用版App配置项
*/
appKeyConfig?: AppKeyConfig;
}


export declare namespace RTCXSDKInit {
export {
init,
uninit,
}
}

初始化

import {
RTCXSDKInit,
RTCXSDKInitTypes,
RTCXCommonTypes,
} from '@rtcx/websdk'

// 初始换SDK,appKey和appSecret是平台分配给PC SDK,在系统中的唯一标识及对应的密钥
const appKeyConfig = new RTCXSDKInitTypes.AppKeyConfig()
appKeyConfig.appKey = 'appKey'
appKeyConfig.appSecret = 'appSecret'
const initConfig = new RTCXSDKInitTypes.InitConfig()
initConfig.appKeyConfig = appKeyConfig
initConfig.debug = false //需要时开启
initConfig.productEnv = RTCXCommonTypes.PlatformEnvEnum.PROD

console.info('checkInitSdk init', initConfig)
RTCXSDKInit.init(initConfig)

示例

import {
RTCXSDKInit,
RTCXSDKInitTypes,
RTCXCommonTypes,
} from '@rtcx/websdk'

// 初始换SDK,appKey和appSecret是平台分配给PC SDK,在系统中的唯一标识及对应的密钥
const appKeyConfig = new RTCXSDKInitTypes.AppKeyConfig()
appKeyConfig.appKey = 'appKey'
appKeyConfig.appSecret = 'appSecret'

//定制环境初始化 开始
appKeyConfig.dataCenterScheme = RTCXCommonTypes.ServerSchemeEnum.HTTPS
appKeyConfig.dataCenterScheme = '定制环境域名'
//如果没有域名分配模块。直接是网关,设置为:DataCenterDomainTypeEnum.GATEWAY
appKeyConfig.dataCenterDomainType = RTCXCommonTypes.DataCenterDomainTypeEnum.GATEWAY
appKeyConfig.domainAutoWidthAK = false
appKeyConfig.signalingScheme = RTCXCommonTypes.ServerSchemeEnum.WSS
appKeyConfig.signalingDomain = '定制环境信令域名'
//定制环境初始化 结束

const initConfig = new RTCXSDKInitTypes.InitConfig()
initConfig.appKeyConfig = appKeyConfig
initConfig.debug = false //需要时开启
initConfig.productEnv = RTCXCommonTypes.PlatformEnvEnum.PROD

console.info('checkInitSdk init', initConfig)
RTCXSDKInit.init(initConfig)
/**
* app配置选项
* @public
*/
declare class AppKeyConfig {
/**
* 数据中心服务协议
*/
dataCenterScheme?: ServerSchemeEnum;
/**
* 数据中心服务域名
*/
dataCenterDomain?: string;
/**
* 数据中心服务域名类型
*/
dataCenterDomainType?: DataCenterDomainTypeEnum;
/**
* 自动加上AK
*/
domainAutoWidthAK?: boolean;
/**
* 信令协议
*/
signalingScheme?: ServerSchemeEnum;
/**
* 信令域名
*/
signalingDomain?: string;
/**
* STUN服务地址
*/
stunAddress?: string;
/**
* 控制台创建的应用key
*/
appKey: string;
/**
* 控制台创建的应用Secret
*/
appSecret: string;
}