import Sdk, { uiconstants, ErrorModel, Emitter } from '../sdk';
/**
* KRtClient
* @description KEDACOM WEBRTC SDK
*/
class KRtcCilent extends Emitter {
/**
* constructor
* @constructor
* @description 构造方法
* @param {object} paramters - 参数对象
* @param {string} [paramters.clientId] - 需要获取信息的实例id
*
* @example
* // 示例1:
* let krtcCilent = new KRtcCilent();
* // 示例2:
* let krtcCilent = new KRtcCilent({
* clientId: "CLIENT12345678"
* });
*/
constructor(paramters = {}) {
paramters = { ...paramters, preVersion: true }
super(paramters);
this.clientId = paramters.clientId;
let singleSdk = new Sdk(paramters);
this._singleSdk = singleSdk;
this._addEventOnSingleSdk()
}
/**
* @function getClientIds
* @description 静态方法 获取可用的SDK实例ID列表
* @return {Array.<string>} clientIds - 包含所有 ClientId 字符串的数组
* @return {string} clientIds.item - ClientId 字符串
*
* @example
* // 示例:
* let clientIdArr = KRtcCilent.getClientIds();
*/
static getClientIds(paramters = {}) {
return Sdk.getClientIds(paramters);
}
/**
* @function getVersion
* @description 静态方法 获取可用的SDK的版本号
* @return {string} 当前sdk的版本号,例如:V6.1.0.4.0.20210518202928
*
* @example
* // 示例:
* KRtcClient.getVersion();
*/
static getVersion() {
return Sdk.getVersion();
}
/*
* @function getClientInfo(暂不提供)
* @description 静态方法 获取可用的SDK实例ID列表
* @param {object} paramters - 参数对象
* @param {string} paramters.clientId - 需要获取信息的实例id
* @return {JSON} 实例的详细信息
*
* @example
* // 示例:
* let clientInfo = KRtcCilent.getClientInfo({
* clientId: "CLIENT12345678"
* });
*/
static getClientInfo(paramters = {}) {
return Sdk.getClientInfo(paramters);
}
/**
* getVersion
* @description 实例方法 获取当前SDK的版本号
* @return {string} 当前sdk的版本号,例如:V6.1.0.4.0.20210518202928
*
* @example
* // 示例:
* krtcClient.getVersion();
*/
getVersion() {
return Sdk.getVersion();
}
/*
* getClientInfo(暂不提供)
* @description 获取可用的SDK实例ID列表
* @return {JSON} 实例信息
*/
getClientInfo() {
return Sdk.getClientInfo(this.clientId);
}
/*
* getUserInfo(暂不提供)
* @description 实例方法 获取当前SDK实例登录的用户信息
* @return {JSON} 登录的用户信息
*/
getUserInfo() {
return this._singleSdk.getUserInfo();
}
/**
* getUserId
* @description 实例方法 获取当前SDK实例登录的用户ID
* @return {string} 字符串,eg:"1234560000000"
*
* @example
* // 示例:
* let userId = krtcCilent.getUserId();
*/
getUserId() {
return this._singleSdk.getUserId() || "";
}
/**
* getNickname
* @description 获取当前用户昵称
* @return {String} nickName - 当前用户昵称,字符串,eg:"游客9527"
*
* @example
* // 示例:
* let nickname = krtcCilent.getNickname();
*/
getNickname() {
return this._singleSdk.getNickname();
}
/**
* getRoomInfo
* @description 获取当前的会议详情,如果还没入会,则返回空对象
* @return {Json} roomInfo - 当前所处会议的详情
*/
getRoomInfo() {
return this._singleSdk.getRoomInfo() || {};
}
/**
* getStatsInfo
* @description 获取订阅/发布流信息
* @return {JSON} 主流音视频发布订阅,双流发布订阅信息
*
*/
getStatsInfo() {
return this._singleSdk.getStatsInfo();
}
/**
* getRoomId
* @description 获取当前的会议号码,如果还没入会,则返回空字符串
* @return {String} roomId - 当前的会议号码,字符串,eg:"6660001"
*
* @example
* // 示例:
* let roomId = krtcCilent.getRoomId();
*/
getRoomId() {
return this._singleSdk.getRoomId();
}
/**
* getUserList
* @description 获取当前的会议的终端列表,如果还没入会,则返回空数组
* @return {Array} Array<UserInfo> 当前会议的终端列表
*/
getUserList() {
return this._singleSdk.getUserList() || [];
}
/**
* getCurrentCamera
* @description 获取当前使用的摄像头
* @return {string} 字符串
*/
getCurrentCamera() {
return this._singleSdk.getCurrentCamera();
}
/**
* getCurrentMicrophone
* @description 获取当前使用的麦克风
* @return {string} 字符串
*/
getCurrentMicrophone() {
return this._singleSdk.getCurrentMicrophone();
}
/**
* getCurrentLoudspeaker
* @description 获取当前使用的扬声器
* @return {string} 字符串
*/
getCurrentLoudspeaker() {
return this._singleSdk.getCurrentLoudspeaker();
}
/**
* init
* @description 初始化SDK
* @param {object} paramters - 参数对象
* @param {string} [paramters.debug] - 是否在浏览器控制台输出调试日志
* @param {string} paramters.hostname - 服务的地址或域名
* @param {string} [paramters.port] - 端口,默认443标准端口
* @param {function} [paramters.success] - 成功回调
* @param {function} [paramters.error] - 失败回调
* @return {object} KRtcCilent 实例
*
* @example
* // 示例:
* krtcClient.init({
* hostname: "172.16.186.220",
* success: function(data) {
* console.log("初始化成功");
* },
* error: function(data) {
* console.log("初始化失败");
* }
* });
*/
init(paramters = {}) {
this._singleSdk.init(paramters)
return this;
}
/**
* autoLogin(暂不提供)
* @description 免登录用户登录
* @param {object} paramters - 参数对象
* @param {string} paramters.roomId - 会议e164
* @param {string} paramters.nickname - 免登录用户昵称
* @param {string} paramters.hostname - 服务的地址或域名
* @param {string} paramters.port - 端口
* @param {boolean} paramters.autoPubLocalStream - 是否自动发布本机音视频流
* @param {boolean} paramters.autoSubAllVideoStream - 自动订阅所有视频流
* @param {function} paramters.success - 成功回调
* @param {function} paramters.error - 失败回调
* @return {object} KRtcCilent 实例
*/
autoLogin(paramters = {}) {
this._singleSdk.autoLogin(paramters);
return this;
}
/**
* login
* @description 登录
* @param {object} paramters - 参数对象
* @param {string} [paramters.userId] - 用户名ID,可选参数,若不传入或为空时分配免登陆账号
* @param {string} paramters.nickname - 用户昵称
* @param {string} paramters.appToken - 应用token
* @param {boolean} paramters.autoPubLocalStream - 是否自动发布本机音视频流
* @param {boolean} paramters.autoSubAllVideoStream - 自动订阅所有视频流
* @param {function} [paramters.success] - 成功回调
* @param {function} [paramters.error] - 失败回调
* @return {object} SkyClient 实例
*
* @example
* // 示例1:使用用户Id为 1234560000000,登录
* krtcClient.login({
* userId: "1234560000000",
* nickname: "172.16.186.220",
* appToken: "TOKEN12345678"
* });
* // 示例2:使用系统分配账号登录
* krtcClient.login({
* nickname: "172.16.186.220",
* appToken: "TOKEN12345678",
* success: function(data) {
* console.log("登录成功");
* },
* error: function(data) {
* console.log("登录失败");
* }
* });
*/
login(paramters = {}) {
this.krtcLogin(paramters);
return this;
}
//krtc登录
krtcLogin(paramters = {}) {
this._singleSdk.krtcLogin(paramters);
return this;
}
/**
* join
* @description 加入会议
* @param {object} paramters - 参数对象
* @param {string} paramters.roomId - 会议E164
* @param {string} [paramters.password] - 密码
* @param {string} [paramters.onAudioReceived] - 接收到声音的回调处理,参数:{ audioTrack: audioTrack }
* @param {function} [paramters.success] - 成功回调
* @param {function} [paramters.error] - 失败回调
* @return {object} KRtcCilent 实例
*
* @example
* // 示例:
* krtcClient.join({
* roomId: "6660001",
* password: "",
* success: function(data) {
* console.log("入会成功");
* },
* error: function(data) {
* console.log("入会失败");
* }
* });
*/
join(paramters = {}) {
paramters.meetingE164 = paramters.roomId;
this._singleSdk.join(paramters);
return this;
}
/**
* accept
* @description 接受被呼
* @param {object} paramters - 参数对象
* @param {string} paramters.roomId - 会议E164
* @param {function} [paramters.success] - 成功回调
* @param {function} [paramters.error] - 失败回调
* @return {object} KRtcCilent 实例
*
* @example
* // 示例:
* krtcClient.accept({
* roomId: "6660001",
* success: function(data) {
* console.log("入会成功");
* },
* error: function(data) {
* console.log("入会失败");
* }
* });
*/
accept(paramters = {}) {
paramters.meetingE164 = paramters.roomId;
this._singleSdk.accept(paramters);
return this;
}
/**
* reject
* @description 拒绝被呼
* @param {object} paramters - 参数对象
* @param {string} paramters.roomId - 会议E164
* @param {function} [paramters.success] - 成功回调
* @param {function} [paramters.error] - 失败回调
* @return {object} KRtcCilent 实例
*
* @example
* // 示例:
* krtcClient.reject({
* roomId: "6660001",
* success: function(data) {
* console.log("拒绝成功");
* },
* error: function(data) {
* console.log("拒绝失败");
* }
* });
*/
reject(paramters = {}) {
paramters.meetingE164 = paramters.roomId;
this._singleSdk.reject(paramters);
return this;
}
/**
* exit
* @description 离开会议
* @param {object} paramters - 参数对象
* @param {string} [paramters.reason] - 离会原因
* @param {function} [paramters.success] - 成功回调
* @param {function} [paramters.error] - 失败回调
* @return {object} KRtcCilent 实例
*
* @example
* // 示例:
* krtcClient.exit({
* reason: "正常离会"
* });
*/
exit(paramters = {}) {
this._singleSdk.exit(paramters);
return this;
}
/**
* destroy
* @description 销毁sdk
*/
destroy() {
console.log("执行销毁")
this._singleSdk.destroy();
return this;
}
/**
* subscribe
* @description 终端订阅(如果已订阅会直接返回,不做处理)
* @param {object} paramters - 参数对象
* @param {string} paramters.userId - 终端id,终端列表返回的终端 编号信息,订阅辅流时可不传
* @param {string} paramters.mediaType - 码流标识:'audio'-订阅音频(暂不支持),'video'-订阅主流视频,'dualvideo'-订阅辅流视频
* @param {string} paramters.quality - 视频流分层标识: low-低分辨率层、middle-中分辨率层、high-高分辨率层
* @param {function} [paramters.success] - 成功回调
* @param {function} [paramters.error] - 失败回调
* @return {object} KRtcCilent 实例
*
* @example
* // 示例1:订阅用户ID为 6660001 的主流视频低分辨率
* krtcClient.subscribe({
* userId: "6660001",
* mediaType: "video",
* quality: "low"
* });
* // 示例2:订阅辅流视频高分辨率
* krtcClient.subscribe({
* mediaType: "dualvideo",
* quality: "high"
* });
*/
subscribe(paramters = {}) {
let { userId, mediaType, quality, error } = paramters;
let dual = (mediaType == "dualvideo") ? true : false;
let confvmp = (mediaType == "confvmp") ? true : false;
let mtid = this._getMtidFromUserId(userId,dual,confvmp);
let layer = quality;
if (!mtid) {
let errorModel = new ErrorModel(null, null, "该终端不存在")
error && error(errorModel)
return this;
}
paramters = { ...paramters, mtid, dual, layer,confvmp }
this._singleSdk.subscribe(paramters);
return this;
}
/**
* subscribeChange
* @description 终端订阅改变(如果已订阅会直接返回,不做处理)
* @param {object} paramters - 参数对象
* @param {string} paramters.userId - 终端id,终端列表返回的终端 编号信息,订阅辅流时可不传
* @param {string} paramters.mediaType - 码流标识:'audio'-订阅音频(暂不支持),'video'-订阅主流视频,'dualvideo'-订阅辅流视频
* @param {string} paramters.quality - 视频流分层标识: low-低分辨率层、middle-中分辨率层、high-高分辨率层
* @param {function} [paramters.success] - 成功回调
* @param {function} [paramters.error] - 失败回调
* @return {object} KRtcCilent 实例
*
* @example
* // 示例1:改变订阅用户ID为 6660001 的主流视频低分辨率
* krtcClient.subscribeChange({
* userId: "6660001",
* mediaType: "video",
* quality: "low"
* });
* // 示例2:改变订阅辅流视频高分辨率
* krtcClient.subscribeChange({
* mediaType: "dualvideo",
* quality: "high"
* });
*/
subscribeChange(paramters) {
let { userId, mediaType, quality, error } = paramters;
let dual = (mediaType == "dualvideo") ? true : false;
let confvmp = (mediaType == "confvmp") ? true : false;
let mtid = this._getMtidFromUserId(userId,dual,confvmp);
let layer = quality;
if (!mtid) {
let errorModel = new ErrorModel(null, null, "该终端不存在")
error && error(errorModel)
return this;
}
paramters = { ...paramters, mtid, dual, layer,confvmp }
this._singleSdk.subscribeChange(paramters)
return this;
}
/**
* unsubscribe
* @description 终端取消订阅(如果已订阅会直接返回,不做处理)
* @param {object} paramters - 参数对象
* @param {string} paramters.userId - 终端id,终端列表返回的终端 编号信息,订阅辅流时可不传
* @param {string} paramters.mediaType - 码流标识:'audio'-音频(暂不支持),'video'-主流视频,'dualvideo'-辅流视频
* @param {function} [paramters.success] - 成功回调
* @param {function} [paramters.error] - 失败回调
* @return {object} KRtcCilent 实例
*
* @example
* // 示例1:取消订阅用户ID为 6660001 的主流视频低分辨率
* krtcClient.unsubscribe({
* userId: "6660001",
* mediaType: "video",
* quality: "low"
* });
* // 示例2:取消订阅辅流视频高分辨率
* krtcClient.unsubscribe({
* mediaType: "dualvideo",
* quality: "high"
* });
*/
unsubscribe(paramters) {
let { userId, mediaType, error } = paramters;
let dual = (mediaType == "dualvideo") ? true : false;
let confvmp = (mediaType == "confvmp") ? true : false;
let mtid = this._getMtidFromUserId(userId,dual,confvmp);
if (!mtid) {
let errorModel = new ErrorModel(null, null, "该终端不存在")
error && error(errorModel)
return this;
}
paramters = { ...paramters, mtid, dual,confvmp }
this._singleSdk.unsubscribe(paramters)
return this;
}
/**
*
* @typedef {Object} DeviceInfoModel - 返回结果对象
* @property {boolean} DeviceInfoModel.success - 是否获取设备成功
* @property {Array<DeviceInfo>} DeviceInfoModel.data 设备列表(Array)
* @property {DeviceInfo} DeviceInfoModel.data.DeviceInfo 单个设备详情
* @property {string} DeviceInfoModel.data.DeviceInfo.deviceId 设备id
* @property {string} DeviceInfoModel.data.DeviceInfo.groupId 设备 groupId
* @property {string} DeviceInfoModel.data.DeviceInfo.kind 设备类型
* @property {string} DeviceInfoModel.data.DeviceInfo.label 设备别名
*/
/**
* listMicrophone
* @description 获取麦克风列表
* @param {object} paramters - 参数对象
* @param {string} [paramters.keyword] - 搜索关键字
* @param {function} [paramters.success] - 成功回调
* @param {function} [paramters.error] - 失败回调
* @return {DeviceInfoModel} DeviceInfoModel - Json 自定义对象
*
* @example
* // 示例:
* krtcClient.listMicrophone({
* keyword: ""
* });
*/
listMicrophone(paramters = {}) {
let model = this._singleSdk.listMicrophone(paramters)
return model;
}
/**
* enableMicrophone
* @description 开启麦克风
* @param {object} paramters - 参数对象
* @param {string} paramters.deviceId - 设备id
* @param {string} [paramters.autoGainControl] - 麦克风增益:true-开启麦克风增益,false-关闭麦克风增益,缺省默认为false
* @param {function} [paramters.success] - 成功回调,参数:{ audioTrack: audioTrack }
* @param {function} [paramters.error] - 失败回调
* @return {object} KRtcCilent 实例
*
* @example
* // 示例:
* krtcClient.enableMicrophone({
* deviceId: "MICROPHONE12345678",
* autoGainControl: true
* });
*/
enableMicrophone(paramters = {}) {
this._singleSdk.enableMicrophone(paramters)
return this;
}
/**
* disableMicrophone
* @description 关闭麦克风
* @param {object} paramters - 参数对象
* @param {function} [paramters.success] - 成功回调
* @param {function} [paramters.error] - 失败回调
* @return {object} KRtcCilent 实例
*
* @example
* // 示例:
* krtcClient.disableMicrophone();
*/
disableMicrophone(paramters = {}) {
this._singleSdk.disableMicrophone(paramters)
return this;
}
/**
* changeMicrophone
* @description 切换麦克风
* @param {object} paramters - 参数对象
* @param {string} paramters.deviceId - 设备id
* @param {string} [paramters.autoGainControl] - 麦克风增益:true-开启麦克风增益,false-关闭麦克风增益,缺省默认为false
* @param {function} [paramters.success] - 成功回调
* @param {function} [paramters.error] - 失败回调
* @return {object} KRtcCilent 实例
*
* @example
* // 示例:
* krtcClient.changeMicrophone({
* deviceId: "MICROPHONE12345678",
* autoGainControl: true
* });
*/
changeMicrophone(paramters = {}) {
this._singleSdk.changeMicrophone(paramters)
return this;
}
/**
* testMicrophone(暂不提供)
* @description 测试麦克风
* @return {JSON}
* abandon
*/
testMicrophone(paramters = {}) {
this._singleSdk.testMicrophone(paramters);
return false;
}
/**
* testMicrophoneVolume
* @description 获取麦克风测试音量
* @param {object} paramters - 参数对象
* @param {function} [paramters.success] - 成功回调
* @param {function} [paramters.error] - 失败回调
* @return {number} 麦克风音量值
*
* @example
* // 示例:可定时获取测试音量用于显示麦克风的能量值
* let volume = krtcClient.testMicrophoneVolume();
*/
testMicrophoneVolume(paramters = {}) {
let volume = this._singleSdk.testMicrophone(paramters);
return volume || "0";
}
/**
* listCamera
* @description 获取摄像头列表
* @param {object} paramters - 参数对象
* @param {string} [paramters.keyword] - 搜索关键字
* @param {function} [paramters.success] - 成功回调
* @param {function} [paramters.error] - 失败回调
* @returns {Object} model - 返回结果
* @returns {boolean} model.success 调用是否成功
* @returns {Array} model.data 设备列表
*
* @example
* // 示例:
* krtcClient.listCamera({
* keyword: ""
* });
*/
listCamera(paramters = {}) {
let model = this._singleSdk.listCamera(paramters)
return model.data;
}
/**
* enableCamera
* @description 开启摄像头
* @param {object} paramters - 参数对象
* @param {string} paramters.deviceId - 扬声器设备id,优先于facingMode
* @param {number} paramters.width - 视频宽度
* @param {number} paramters.height - 视频高度
* @param {number} paramters.definition - 分辨率,值为360P,720P
* @param {string} paramters.facingMode - 移动设备的前后置摄像头:environment-后置摄像头,user-前置摄像头
* @param {function} [paramters.success] - 成功回调
* @param {function} [paramters.error] - 失败回调
* @return {object} KRtcCilent 实例
*/
enableCamera(paramters = {}) {
this._singleSdk.enableCamera(paramters)
return this;
}
/**
* disableCamera
* @description 关闭摄像头
* @param {object} paramters - 参数对象
* @param {boolean} paramters.isTest - 是否测试模式:true-是,false-否
* @param {function} [paramters.success] - 成功回调
* @param {function} [paramters.error] - 失败回调
* @return {object} KRtcCilent 实例
*/
disableCamera(paramters = {}) {
this._singleSdk.disableCamera(paramters)
return this;
}
/**
* changeCamera
* @description 切换摄像头
* @param {object} paramters - 参数对象
* @param {string} paramters.deviceId - 扬声器设备id,优先于facingMode
* @param {number} paramters.width - 视频宽度
* @param {number} paramters.height - 视频高度
* @param {string} paramters.facingMode - 移动设备的前后置摄像头:environment-后置摄像头,user-前置摄像头
* @param {function} [paramters.success] - 成功回调
* @param {function} [paramters.error] - 失败回调
* @return {object} KRtcCilent 实例
*/
changeCamera(paramters = {}) {
this._singleSdk.enableCamera(paramters)
return this;
}
/**
* listLoudspeaker
* @description 获取扬声器列表
* @param {object} paramters - 参数对象
* @param {string} [paramters.keyword] - 搜索关键字
* @param {function} [paramters.success] - 成功回调
* @param {function} [paramters.error] - 失败回调
* @return {DeviceInfoModel} 扬声器列表 (JSON) 自定义对象
*
* @example
* // 示例:
* krtcClient.listLoudspeaker({
* keyword: ""
* });
*/
listLoudspeaker(paramters = {}) {
let model = this._singleSdk.listLoudspeaker(paramters)
return model;
}
/**
* enableLoudspeaker
* @description 开启扬声器
* @param {object} paramters - 参数对象
* @param {string} paramters.deviceId - 扬声器设备id
* @param {function} [paramters.success] - 成功回调
* @param {function} [paramters.error] - 失败回调
* @return {object} KRtcCilent 实例
*/
enableLoudspeaker(paramters = {}) {
this._singleSdk.enableLoudspeaker(paramters)
return this;
}
/**
* disableLoudspeaker
* @description 关闭扬声器
* @param {object} paramters - 参数对象
* @param {function} [paramters.success] - 成功回调
* @param {function} [paramters.error] - 失败回调
* @return {object} KRtcCilent 实例
*/
disableLoudspeaker(paramters = {}) {
this._singleSdk.disableLoudspeaker(paramters)
return this;
}
/**
* changeLoudspeaker
* @description 切换扬声器
* @param {object} paramters - 参数对象
* @param {string} paramters.deviceId - 扬声器设备id
* @param {function} [paramters.success] - 成功回调
* @param {function} [paramters.error] - 失败回调
* @return {object} KRtcCilent 实例
*/
changeLoudspeaker(paramters = {}) {
this._singleSdk.changeLoudspeaker(paramters)
return this;
}
/**
* testLoudspeaker
* @description 开始测试扬声器
* @param {object} paramters - 参数对象
* @param {boolean} paramters.playstatus - 当前是否正在播放,true-正在播放,false-未播放
* @param {string} paramters.deviceId - 扬声器设备id
* @param {function} [paramters.success] - 成功回调
* @param {function} [paramters.error] - 失败回调
* @return {object} KRtcCilent 实例
*/
testLoudspeaker(paramters = {}) {
this._singleSdk.testLoudspeaker(paramters);
return this;
}
/**
* stopTestLoudspeaker
* @description 停止测试扬声器
* @param {object} paramters - 参数对象
* @param {string} paramters.deviceId - 扬声器设备id
* @param {function} [paramters.success] - 成功回调
* @param {function} [paramters.error] - 失败回调
* @return {object} KRtcCilent 实例
*/
stopTestLoudspeaker(paramters = {}) {
this._singleSdk.stopTestLoudspeaker(paramters);
return this;
}
/**
* testLoudspeakerVolume
* @description 获取扬声器测试音量
* @return {string} 扬声器音量值
*/
testLoudspeakerVolume() {
let volume = this._singleSdk.stopTestLoudspeaker(paramters);
return volume || "0";
}
/**
* enableShare
* @description 开启屏幕共享
* @param {object} paramters - 参数对象
* @param {number} paramters.width - 视频宽度
* @param {number} paramters.height - 视频高度
* @param {number} paramters.frameRate - 视频最大帧率
* @param {function} [paramters.success] - 成功回调
* @param {function} [paramters.error] - 失败回调
* @return {object} KRtcCilent 实例
*/
enableShare(paramters = {}) {
this._singleSdk.enableShare(paramters);
return this;
}
/**
* disableShare
* @description 关闭屏幕共享
* @param {object} paramters - 参数对象
* @param {function} [paramters.success] - 成功回调
* @param {function} [paramters.error] - 失败回调
* @return {object} KRtcCilent 实例
*/
disableShare(paramters = {}) {
this._singleSdk.disableShare(paramters);
return this;
}
// 由UserId转换为 mtid
_getMtidFromUserId(userId,dual,confvmp) {
let { mtList } = this._singleSdk.sdkStore;
let peers = mtList.peers;
let mtid;
for (let key in peers) {
let peer = peers[key]
if (peer.e164 == userId) {
mtid = peer.mtId;
break;
}else if(confvmp){
mtid = "confvmp";
break;
}
}
return mtid || "";
}
// 由Mtid 转换为UserId
_getUserIdFromMtid(mtid) {
let { mtList } = this._singleSdk.sdkStore;
let peers = mtList.peers;
return peers[mtid] ? peers[mtid]["e164"] : "";
}
_addEventOnSingleSdk() {
let that = this;
let eventList = Object.values(uiconstants);
eventList.forEach(eventName => {
this._singleSdk.on(eventName, function (data) {
// console.log("_addEventOnSingleSdk eventName = ", eventName)
// console.log("_addEventOnSingleSdk data = ", data)
that.emit(eventName, data)
})
});
}
}
export default KRtcCilent;
export { uiconstants };