@tencentcloud/call-uikit-wechat
Advanced tools
Comparing version 3.3.2 to 3.3.3-beta.1
{ | ||
"name": "@tencentcloud/call-uikit-wechat", | ||
"version": "3.3.2", | ||
"version": "3.3.3-beta.1", | ||
"main": "./tuicall-uikit-vue.umd.js", | ||
@@ -18,3 +18,3 @@ "module": "./tuicall-uikit-vue.es.js", | ||
"@tencentcloud/tui-core": "latest", | ||
"tuicall-engine-wx": "latest" | ||
"tuicall-engine-wx": "2.2.4-beta.1" | ||
}, | ||
@@ -21,0 +21,0 @@ "bugs": { |
@@ -25,3 +25,3 @@ export const VirtualBackgroundMobileConfig = { | ||
], [ | ||
{ name: 'virtualBackground', customStyle: { justifyContent: 'center', paddingTop: '6vh' } }, | ||
{ name: 'virtualBackground', customStyle: { justifyContent: 'center', paddingTop: '6vh' }, props: {} }, | ||
{ name: 'hangup', customStyle: { paddingTop: '6vh' } }, | ||
@@ -28,0 +28,0 @@ { name: 'switchCamera', customStyle: { justifyContent: 'center', paddingTop: '6vh' }, props: {} }, |
@@ -158,2 +158,10 @@ import { TUIGlobal } from '../../../../TUICallService/index'; | ||
}, | ||
disableConfig: { | ||
...initialStyle, | ||
color: '#6b758a4d', | ||
iconSrc: VirtualBackgroundOpenSrc, | ||
buttonStyle: { | ||
opacity: 0.6 | ||
} | ||
} | ||
}, | ||
@@ -175,2 +183,12 @@ }; | ||
}, | ||
disableConfig: { | ||
...initialStyle, | ||
color: '#6b758a4d', | ||
iconSrc: SwitchCameraSrc, | ||
shape: 'circle', | ||
showText: true, | ||
buttonStyle: { | ||
opacity: 0.6 | ||
} | ||
} | ||
}, | ||
@@ -201,2 +219,12 @@ hangup: { | ||
}, | ||
disableConfig: { | ||
...initialStyle, | ||
color: '#6b758a4d', | ||
iconSrc: SwitchCameraSrc, | ||
shape: 'circle', | ||
showText: true, | ||
buttonStyle: { | ||
opacity: 0.6 | ||
} | ||
} | ||
}, | ||
@@ -232,2 +260,11 @@ accept: { | ||
}, | ||
disableConfig: { | ||
...initialStyle, | ||
color: 'transparent', | ||
iconSrc: VirtualBackgroundOpenSrc, | ||
showText: false, | ||
buttonStyle: { | ||
opacity: 0.6 | ||
} | ||
} | ||
}, | ||
@@ -249,2 +286,9 @@ hangup: { | ||
}, | ||
disableConfig: { | ||
...defaultButtonUI.switchCamera.basicConfig, | ||
showText: false, | ||
buttonStyle: { | ||
opacity: 0.6 | ||
} | ||
} | ||
}, | ||
@@ -251,0 +295,0 @@ } |
@@ -1,7 +0,8 @@ | ||
import { watch, ref, toRefs } from '../../adapter-vue'; | ||
import { watch, ref, toRefs, computed } from '../../adapter-vue'; | ||
import { useCustomUI } from './useCustomUI'; | ||
import { TUIGlobal } from '../../TUICallService'; | ||
import { TUIGlobal, CallStatus } from '../../TUICallService'; | ||
import { add, deepClone, findValues, modify } from '../util'; | ||
import { VirtualBackgroundMobileConfig } from '../components/common/ButtonPanel/config/VirtualBackgroundMobileConfig'; | ||
import { useCallInfoContext } from './useCallInfoContext'; | ||
import { useUserInfoExcludeVolumeContext } from './useUserInfoContextExcludeVolume'; | ||
import { ButtonPanelConfig } from '../components/common/ButtonPanel/config/InitConfig'; | ||
@@ -12,21 +13,44 @@ | ||
modify(newConfig, 'mobile.singleCall.video', VirtualBackgroundMobileConfig); | ||
add(newConfig, 'pc.singleCall.video.calling[0][2]', { name: 'virtualBackground' }); | ||
add(newConfig, 'pc.singleCall.video.accept[0][1]', { name: 'virtualBackground' }); | ||
add(newConfig, 'pc.singleCall.video.connected[0][3]', { name: 'virtualBackground' }); | ||
add(newConfig, 'pc.groupCall.video.calling[0][3]', { name: 'virtualBackground' }); | ||
add(newConfig, 'pc.groupCall.video.connected[0][4]', { name: 'virtualBackground' }); | ||
add(newConfig, 'pc.singleCall.video.calling[0][2]', { name: 'virtualBackground', props: {} }); | ||
add(newConfig, 'pc.singleCall.video.accept[0][1]', { name: 'virtualBackground', props: {} }); | ||
add(newConfig, 'pc.singleCall.video.connected[0][3]', { name: 'virtualBackground', props: {} }); | ||
add(newConfig, 'pc.groupCall.video.calling[0][3]', { name: 'virtualBackground', props: {} }); | ||
add(newConfig, 'pc.groupCall.video.connected[0][4]', { name: 'virtualBackground', props: {} }); | ||
return newConfig; | ||
} | ||
function setCloseCameraConfig(config, isVideoAvailable, isShowVirtualBackgroundIcon) { | ||
let newConfig = deepClone(config); | ||
if(isVideoAvailable){ | ||
modify(newConfig, 'mobile.singleCall.video.connected[1][2].props.show', true); | ||
if(isShowVirtualBackgroundIcon) { | ||
setVirtualBackgroundConfig(newConfig); | ||
} | ||
} else { | ||
modify(newConfig, 'mobile.singleCall.video.connected[1][2].props.show', false); | ||
if(isShowVirtualBackgroundIcon) { | ||
modify(newConfig, 'mobile.singleCall.video.connected[1][0].props.show', false); | ||
modify(newConfig, 'pc.singleCall.video.connected[0][3].props.show', false); | ||
modify(newConfig, 'pc.groupCall.video.connected[0][4].props.show', false); | ||
} | ||
} | ||
return newConfig; | ||
} | ||
export function useCustomUIButtonConfig() { | ||
const { isShowEnableVirtualBackground } = toRefs(useCallInfoContext()); | ||
const { isShowEnableVirtualBackground, callStatus } = toRefs(useCallInfoContext()); | ||
const customUIConfig = useCustomUI(); | ||
const { localUserInfoExcludeVolume: localUserInfo } = toRefs(useUserInfoExcludeVolumeContext()); | ||
const isVideoAvailable = computed(() => localUserInfo?.value.isVideoAvailable || false); | ||
const isShowVirtualBackgroundIcon = computed(() => isShowEnableVirtualBackground.value && !TUIGlobal.isH5); | ||
const results = ref([]); | ||
watch([customUIConfig, isShowEnableVirtualBackground], () => { | ||
watch([customUIConfig, isShowEnableVirtualBackground, isVideoAvailable], () => { | ||
let initConfig = deepClone(ButtonPanelConfig); | ||
if (isShowEnableVirtualBackground.value && !TUIGlobal.isH5) { | ||
if (isShowVirtualBackgroundIcon.value) { | ||
initConfig = setVirtualBackgroundConfig(ButtonPanelConfig); | ||
} | ||
if(callStatus.value === CallStatus.CONNECTED) { | ||
initConfig = setCloseCameraConfig(initConfig, isVideoAvailable.value, isShowVirtualBackgroundIcon.value); | ||
} | ||
const { button: buttonsConfig } = customUIConfig.value; | ||
@@ -33,0 +57,0 @@ const rs = []; |
@@ -17,3 +17,3 @@ import { | ||
} from './TUICallService/index'; | ||
const Version = '3.3.2'; // basic-demo 原来上报使用 | ||
const Version = '3.3.3-beta.1'; // basic-demo 原来上报使用 | ||
@@ -20,0 +20,0 @@ // 输出产物 |
@@ -17,2 +17,3 @@ import { CallStatus, NAME, CallRole } from '../const/index'; | ||
this._bellContext = wx.createInnerAudioContext(); | ||
this?._addListenBellContextEvent(); | ||
this._bellContext.loop = true; | ||
@@ -81,2 +82,3 @@ } | ||
this._callStatus = CallStatus.IDLE; | ||
this?._removeListenBellContextEvent(); | ||
this._bellContext.destroy(); | ||
@@ -88,2 +90,25 @@ this._bellContext = null; | ||
} | ||
private async _handleAudioInterruptionBegin() { | ||
await this.stop(); | ||
} | ||
private async _handleAudioInterruptionEnd() { | ||
await this.play(); | ||
} | ||
private _handleBellContextError(errMsg, errorCode) { | ||
console.log('bellContext', errMsg, errorCode); | ||
} | ||
private _addListenBellContextEvent() { | ||
this._bellContext?.onError(this._handleBellContextError); | ||
// @ts-ignore | ||
wx.onAudioInterruptionBegin(this._handleAudioInterruptionBegin); | ||
// @ts-ignore | ||
wx.onAudioInterruptionEnd(this._handleAudioInterruptionEnd); | ||
} | ||
private _removeListenBellContextEvent() { | ||
this._bellContext.offError(this._handleBellContextError); | ||
// @ts-ignore | ||
wx.offAudioInterruptionBegin(this._handleAudioInterruptionBegin); | ||
// @ts-ignore | ||
wx.offAudioInterruptionEnd(this._handleAudioInterruptionEnd); | ||
} | ||
} |
@@ -1,66 +0,26 @@ | ||
import { TUICore, TUILogin, TUIConstants, ExtensionInfo } from '@tencentcloud/tui-core'; | ||
import { | ||
ITUICallService, | ||
ICallParams, | ||
IGroupCallParams, | ||
IUserInfo, | ||
ICallbackParam, | ||
ISelfInfoParams, | ||
IBellParams, | ||
IInviteUserParams, | ||
IJoinInGroupCallParams, | ||
IInitParams, | ||
ITUICallService, ICallParams, IGroupCallParams, IUserInfo, ICallbackParam, ISelfInfoParams, IBellParams, | ||
IInviteUserParams, IJoinInGroupCallParams, IInitParams, | ||
} from '../interface/ICallService'; | ||
import { | ||
StoreName, | ||
CallStatus, | ||
CallMediaType, | ||
NAME, | ||
CALL_DATA_KEY, | ||
LanguageType, | ||
CallRole, | ||
LOG_LEVEL, | ||
VideoDisplayMode, | ||
VideoResolution, | ||
StatusChange, | ||
AudioCallIcon, | ||
VideoCallIcon, | ||
ErrorCode, | ||
ErrorMessage, | ||
AudioPlayBackDevice, | ||
CameraPosition, | ||
COMPONENT, | ||
FeatureButton, | ||
ButtonState, | ||
LayoutMode, | ||
DEFAULT_BLUR_LEVEL, | ||
NETWORK_QUALITY_THRESHOLD, | ||
DeviceType, | ||
StoreName, CallStatus, CallMediaType, NAME, CALL_DATA_KEY, LanguageType, CallRole, LOG_LEVEL, VideoDisplayMode, | ||
VideoResolution, StatusChange, AudioPlayBackDevice, CameraPosition, COMPONENT, FeatureButton, ButtonState, | ||
LayoutMode, DEFAULT_BLUR_LEVEL, | ||
} from '../const/index'; | ||
// @ts-ignore | ||
import { TUICallEngine, EVENT as TUICallEvent } from 'tuicall-engine-wx'; | ||
// @ts-ignore | ||
import TencentCloudChat from '@tencentcloud/chat'; | ||
import { TUICallEngine } from 'tuicall-engine-wx'; | ||
import { beforeCall, handlePackageError, handleNoPusherCapabilityError } from './miniProgram'; | ||
import { CallTips, t } from '../locales/index'; | ||
import { initAndCheckRunEnv, beforeCall, handlePackageError, handleNoPusherCapabilityError } from './miniProgram'; | ||
import { BellContext } from './bellContext'; | ||
import { VALIDATE_PARAMS, avoidRepeatedCall, paramValidate } from '../utils/validate/index'; | ||
import { handleRepeatedCallError, handleNoDevicePermissionError, formatTime, performanceNow, isUndefined } from '../utils/common-utils'; | ||
import { | ||
getMyProfile, | ||
getRemoteUserProfile, | ||
generateText, | ||
generateStatusChangeText, | ||
getGroupMemberList, | ||
getGroupProfile, | ||
getGroupAttributes, | ||
updateStoreBasedOnGroupAttributes, | ||
updateRoomIdAndRoomIdType, | ||
} from './utils'; | ||
import { VALIDATE_PARAMS, avoidRepeatedCall, paramValidate, statusValidate } from '../utils/validate/index'; | ||
import { handleRepeatedCallError, formatTime, performanceNow } from '../utils/common-utils'; | ||
import { getRemoteUserProfile, generateStatusChangeText, noDevicePermissionToast, setLocalUserInfoAudioVideoAvailable, | ||
getGroupMemberList, getGroupProfile, updateRoomIdAndRoomIdType, updateDeviceList } from './utils'; | ||
import timer from '../utils/timer'; | ||
import { ITUIGlobal } from '../interface/ITUIGlobal'; | ||
import { ITUIStore } from '../interface/ITUIStore'; | ||
import { ITUIGlobal, ITUIStore } from '../interface/index'; | ||
import TuiGlobal from '../TUIGlobal/tuiGlobal'; | ||
import TuiStore from '../TUIStore/tuiStore'; | ||
import { UIDesign } from './UIDesign'; | ||
import ChatCombine from './chatCombine'; | ||
import EngineEventHandler from './engineEventHandler'; | ||
const TUIGlobal: ITUIGlobal = TuiGlobal.getInstance(); | ||
@@ -70,3 +30,3 @@ const TUIStore: ITUIStore = TuiStore.getInstance(); | ||
uiDesign.setTUIStore(TUIStore); | ||
const version = '3.3.2'; | ||
const version = '3.3.3-beta.1'; | ||
export { TUIGlobal, TUIStore, uiDesign }; | ||
@@ -88,2 +48,5 @@ | ||
}; | ||
private _chatCombine: any = null; | ||
private _engineEventHandler: any = null; | ||
constructor() { | ||
@@ -93,11 +56,4 @@ console.log(`${NAME.PREFIX}version: ${version}`); | ||
this._bellContext = new BellContext(); | ||
// 下面:TUICore注册事件,注册组件服务,注册界面拓展 | ||
TUICore.registerEvent(TUIConstants.TUILogin.EVENT.LOGIN_STATE_CHANGED, TUIConstants.TUILogin.EVENT_SUB_KEY.USER_LOGIN_SUCCESS, this); | ||
// @ts-ignore | ||
if (TUIConstants.TUIChat?.EVENT) { | ||
// @ts-ignore | ||
TUICore.registerEvent(TUIConstants.TUIChat.EVENT?.CHAT_STATE_CHANGED, TUIConstants.TUIChat.EVENT_SUB_KEY?.CHAT_OPENED, this); | ||
} | ||
TUICore.registerService(TUIConstants.TUICalling.SERVICE.NAME, this); | ||
TUICore.registerExtension(TUIConstants.TUIChat.EXTENSION.INPUT_MORE.EXT_ID, this); | ||
this._chatCombine = ChatCombine.getInstance({ callService: this }); | ||
this._engineEventHandler = EngineEventHandler.getInstance({ callService: this }); | ||
} | ||
@@ -169,2 +125,3 @@ static getInstance() { | ||
@paramValidate(VALIDATE_PARAMS.call) | ||
@statusValidate({ engineInstance: true }) | ||
public async call(callParams: ICallParams) { | ||
@@ -176,3 +133,3 @@ if (TUIStore.getData(StoreName.CALL, NAME.CALL_STATUS) !== CallStatus.IDLE) return; // avoid double click when application stuck | ||
await this._updateCallStoreBeforeCall(type, [{ userId: userID }]); | ||
this._executeExternalBeforeCalling(); // 执行外部传入的 beforeCall 方法 | ||
this.executeExternalBeforeCalling(); // 执行外部传入的 beforeCall 方法 | ||
callParams.offlinePushInfo = { ...this._defaultOfflinePushInfo, ...offlinePushInfo }; | ||
@@ -187,2 +144,3 @@ const response = await this._tuiCallEngine.call(callParams); | ||
@paramValidate(VALIDATE_PARAMS.groupCall) | ||
@statusValidate({ engineInstance: true }) | ||
public async groupCall(groupCallParams: IGroupCallParams) { | ||
@@ -195,3 +153,3 @@ if (TUIStore.getData(StoreName.CALL, NAME.CALL_STATUS) !== CallStatus.IDLE) return; // avoid double click when application stuck | ||
await this._updateCallStoreBeforeCall(type, remoteUserInfoList, groupID); | ||
this._executeExternalBeforeCalling(); | ||
this.executeExternalBeforeCalling(); | ||
groupCallParams.offlinePushInfo = { ...this._defaultOfflinePushInfo, ...offlinePushInfo }; | ||
@@ -206,2 +164,3 @@ const response = await this._tuiCallEngine.groupCall(groupCallParams); | ||
@paramValidate(VALIDATE_PARAMS.inviteUser) | ||
@statusValidate({ engineInstance: true }) | ||
public async inviteUser(params: IInviteUserParams) { | ||
@@ -211,3 +170,3 @@ if (TUIStore.getData(StoreName.CALL, NAME.CALL_STATUS) === CallStatus.IDLE) return; // avoid double click when application stuck | ||
const { userIDList } = params; | ||
let inviteUserInfoList = await getRemoteUserProfile(userIDList, this.getTim(), TUIStore); | ||
let inviteUserInfoList = await getRemoteUserProfile(userIDList, this.getTim()); | ||
const remoteUserInfoList = TUIStore.getData(StoreName.CALL, NAME.REMOTE_USER_INFO_LIST); | ||
@@ -225,2 +184,3 @@ TUIStore.update(StoreName.CALL, NAME.REMOTE_USER_INFO_LIST, [...remoteUserInfoList, ...inviteUserInfoList]); | ||
@paramValidate(VALIDATE_PARAMS.joinInGroupCall) | ||
@statusValidate({ engineInstance: true }) | ||
public async joinInGroupCall(params: IJoinInGroupCallParams) { | ||
@@ -239,6 +199,6 @@ if (TUIStore.getData(StoreName.CALL, NAME.CALL_STATUS) === CallStatus.CONNECTED) return; // avoid double click when application stuck | ||
const response = await this._tuiCallEngine.joinInGroupCall(params); | ||
const isCameraDefaultStateClose = this.getFeatureButtonDefaultState(FeatureButton.Camera) === ButtonState.Close; | ||
const isCameraDefaultStateClose = this._getFeatureButtonDefaultState(FeatureButton.Camera) === ButtonState.Close; | ||
(params.type === CallMediaType.VIDEO) && !isCameraDefaultStateClose && await this.openCamera(NAME.LOCAL_VIDEO); | ||
TUIStore.update(StoreName.CALL, NAME.IS_CLICKABLE, true); | ||
this._startTimer(); | ||
this.startTimer(); | ||
TUIStore.update(StoreName.CALL, NAME.PUSHER, response); | ||
@@ -249,3 +209,3 @@ this.setSoundMode(params.type === CallMediaType.AUDIO ? AudioPlayBackDevice.EAR : AudioPlayBackDevice.SPEAKER); | ||
TUIStore.update(StoreName.CALL, NAME.LOCAL_USER_INFO_EXCLUDE_VOLUMN, { ...localUserInfo, isEnter: true }); | ||
this._setLocalUserInfoAudioVideoAvailable(true, NAME.AUDIO); | ||
setLocalUserInfoAudioVideoAvailable(true, NAME.AUDIO); | ||
} catch (error) { | ||
@@ -263,4 +223,4 @@ this._handleCallError(error, 'joinInGroupCall'); | ||
@paramValidate(VALIDATE_PARAMS.setLanguage) | ||
public setLanguage(language: LanguageType) { | ||
if (language && Object.values(LanguageType).includes(language)) { | ||
public setLanguage(language: string) { | ||
if (language && Object.values(LanguageType).includes(language as LanguageType)) { | ||
TUIStore.update(StoreName.CALL, NAME.LANGUAGE, language); | ||
@@ -335,7 +295,7 @@ } | ||
TUIStore.update(StoreName.CALL, NAME.CALL_STATUS, CallStatus.CONNECTED); | ||
this._callTUIService({ message: response?.data?.message }); | ||
this._chatCombine?.callTUIService({ message: response?.data?.message }); | ||
TUIStore.update(StoreName.CALL, NAME.IS_CLICKABLE, true); | ||
this._startTimer(); | ||
this.startTimer(); | ||
const callMediaType = TUIStore.getData(StoreName.CALL, NAME.CALL_MEDIA_TYPE); | ||
const isCameraDefaultStateClose = this.getFeatureButtonDefaultState(FeatureButton.Camera) === ButtonState.Close; | ||
const isCameraDefaultStateClose = this._getFeatureButtonDefaultState(FeatureButton.Camera) === ButtonState.Close; | ||
(callMediaType === CallMediaType.VIDEO) && !isCameraDefaultStateClose && await this.openCamera(NAME.LOCAL_VIDEO); | ||
@@ -347,3 +307,3 @@ response.pusher && TUIStore.update(StoreName.CALL, NAME.PUSHER, response.pusher); | ||
TUIStore.update(StoreName.CALL, NAME.LOCAL_USER_INFO_EXCLUDE_VOLUMN, { ...localUserInfo, isEnter: true }); | ||
this._setLocalUserInfoAudioVideoAvailable(true, NAME.AUDIO); // web && mini default open audio | ||
setLocalUserInfoAudioVideoAvailable(true, NAME.AUDIO); // web && mini default open audio | ||
} | ||
@@ -357,3 +317,3 @@ } catch (error) { | ||
if (handleRepeatedCallError(error)) return; | ||
this._noDevicePermissionToast(error, CallMediaType.AUDIO); | ||
noDevicePermissionToast(error, CallMediaType.AUDIO, this._tuiCallEngine); | ||
this._resetCallStore(); | ||
@@ -369,3 +329,3 @@ } | ||
if (item?.code === 0) { | ||
this._callTUIService({ message: item?.data?.message }); | ||
this._chatCombine?.callTUIService({ message: item?.data?.message }); | ||
} | ||
@@ -384,3 +344,3 @@ }); | ||
if (response?.code === 0) { | ||
this._callTUIService({ message: response?.data?.message }); | ||
this._chatCombine?.callTUIService({ message: response?.data?.message }); | ||
} | ||
@@ -396,5 +356,5 @@ } catch (error) { | ||
await this._tuiCallEngine.openCamera(); | ||
this._setLocalUserInfoAudioVideoAvailable(true, NAME.VIDEO); | ||
setLocalUserInfoAudioVideoAvailable(true, NAME.VIDEO); | ||
} catch (error: any) { | ||
this._noDevicePermissionToast(error, CallMediaType.VIDEO); | ||
noDevicePermissionToast(error, CallMediaType.VIDEO, this._tuiCallEngine); | ||
console.error(`${NAME.PREFIX}openCamera error: ${error}.`); | ||
@@ -407,3 +367,3 @@ } | ||
await this._tuiCallEngine.closeCamera(); | ||
this._setLocalUserInfoAudioVideoAvailable(false, NAME.VIDEO); | ||
setLocalUserInfoAudioVideoAvailable(false, NAME.VIDEO); | ||
} catch (error: any) { | ||
@@ -417,3 +377,3 @@ console.error(`${NAME.PREFIX}closeCamera error: ${error}.`); | ||
await this._tuiCallEngine.openMicrophone(); | ||
this._setLocalUserInfoAudioVideoAvailable(true, NAME.AUDIO); | ||
setLocalUserInfoAudioVideoAvailable(true, NAME.AUDIO); | ||
} catch (error: any) { | ||
@@ -427,3 +387,3 @@ console.error(`${NAME.PREFIX}openMicrophone failed, error: ${error}.`); | ||
await this._tuiCallEngine.closeMicrophone(); | ||
this._setLocalUserInfoAudioVideoAvailable(false, NAME.AUDIO); | ||
setLocalUserInfoAudioVideoAvailable(false, NAME.AUDIO); | ||
} catch (error: any) { | ||
@@ -449,3 +409,3 @@ console.error(`${NAME.PREFIX}closeMicrophone failed, error: ${error}.`); | ||
if (response?.code === 0) { | ||
this._callTUIService({ message: response?.data?.message }); | ||
this._chatCombine?.callTUIService({ message: response?.data?.message }); | ||
} | ||
@@ -455,3 +415,3 @@ TUIStore.update(StoreName.CALL, NAME.CALL_MEDIA_TYPE, CallMediaType.AUDIO); | ||
const oldStatus = isGroup ? StatusChange.CALLING_GROUP_VIDEO : StatusChange.CALLING_C2C_VIDEO; | ||
const newStatus = generateStatusChangeText(TUIStore); | ||
const newStatus = generateStatusChangeText(); | ||
this.statusChanged && this.statusChanged({ oldStatus, newStatus }); | ||
@@ -490,11 +450,2 @@ this.setSoundMode(AudioPlayBackDevice.EAR); | ||
} | ||
// 切前后置 miniProgram, 切扬声器 | ||
public getTim() { | ||
if (this._tim) return this._tim; | ||
if (!this._tuiCallEngine) { | ||
console.warn(`${NAME.PREFIX}getTim warning: _tuiCallEngine Instance is not available.`); | ||
return null; | ||
} | ||
return this._tuiCallEngine?.tim || this._tuiCallEngine?.getTim(); // mini support getTim interface | ||
} | ||
@avoidRepeatedCall() | ||
@@ -510,267 +461,7 @@ public async setBlurBackground(enable: boolean) { | ||
private _addListenTuiCallEngineEvent() { | ||
if (!this._tuiCallEngine) { | ||
console.warn(`${NAME.PREFIX}add engine event listener failed, engine is empty.`); | ||
return; | ||
} | ||
this._tuiCallEngine.on(TUICallEvent.ERROR, this._handleError, this); | ||
this._tuiCallEngine.on(TUICallEvent.INVITED, this._handleNewInvitationReceived, this); // 收到邀请事件 | ||
this._tuiCallEngine.on(TUICallEvent.USER_ACCEPT, this._handleUserAccept, this); // 主叫收到被叫接通事件 | ||
this._tuiCallEngine.on(TUICallEvent.USER_ENTER, this._handleUserEnter, this); // 有用户进房事件 | ||
this._tuiCallEngine.on(TUICallEvent.USER_LEAVE, this._handleUserLeave, this); // 有用户离开通话事件 | ||
this._tuiCallEngine.on(TUICallEvent.REJECT, this._handleInviteeReject, this); // 主叫收到被叫的拒绝通话事件 | ||
this._tuiCallEngine.on(TUICallEvent.NO_RESP, this._handleNoResponse, this); // 主叫收到被叫的无应答事件 | ||
this._tuiCallEngine.on(TUICallEvent.LINE_BUSY, this._handleLineBusy, this); // 主叫收到被叫的忙线事件 | ||
this._tuiCallEngine.on(TUICallEvent.CALLING_CANCEL, this._handleCallingCancel, this); // 主被叫在通话未建立时, 收到的取消事件 | ||
this._tuiCallEngine.on(TUICallEvent.SDK_READY, this._handleSDKReady, this); // SDK Ready 回调 | ||
this._tuiCallEngine.on(TUICallEvent.KICKED_OUT, this._handleKickedOut, this); // 未开启多端登录时, 多端登录收到的被踢事件 | ||
this._tuiCallEngine.on(TUICallEvent.MESSAGE_SENT_BY_ME, this._messageSentByMe, this); | ||
// @ts-ignore | ||
TUICallEvent.ON_USER_NETWORK_QUALITY_CHANGED && this._tuiCallEngine.on(TUICallEvent.ON_USER_NETWORK_QUALITY_CHANGED, this._handleNetworkQuality, this); // 用户网络质量 | ||
this._tuiCallEngine.on(TUICallEvent.CALL_END, this._handleCallingEnd, this); // 主被叫在通话结束时, 收到的通话结束事件 | ||
// @ts-ignore | ||
this._tuiCallEngine.on(TUICallEvent.CALL_MODE, this._handleCallTypeChange, this); | ||
// @ts-ignore | ||
this._tuiCallEngine.on(TUICallEvent.USER_UPDATE, this._handleUserUpdate, this); // mini: user data update | ||
this._engineEventHandler.addListenTuiCallEngineEvent(); | ||
} | ||
private _removeListenTuiCallEngineEvent() { | ||
this._tuiCallEngine.off(TUICallEvent.ERROR, this._handleError); | ||
this._tuiCallEngine.off(TUICallEvent.INVITED, this._handleNewInvitationReceived); | ||
this._tuiCallEngine.off(TUICallEvent.USER_ACCEPT, this._handleUserAccept); | ||
this._tuiCallEngine.off(TUICallEvent.USER_ENTER, this._handleUserEnter); | ||
this._tuiCallEngine.off(TUICallEvent.USER_LEAVE, this._handleUserLeave); | ||
this._tuiCallEngine.off(TUICallEvent.REJECT, this._handleInviteeReject); | ||
this._tuiCallEngine.off(TUICallEvent.NO_RESP, this._handleNoResponse); | ||
this._tuiCallEngine.off(TUICallEvent.LINE_BUSY, this._handleLineBusy); | ||
this._tuiCallEngine.off(TUICallEvent.CALLING_CANCEL, this._handleCallingCancel); | ||
this._tuiCallEngine.off(TUICallEvent.SDK_READY, this._handleSDKReady); | ||
this._tuiCallEngine.off(TUICallEvent.KICKED_OUT, this._handleKickedOut); | ||
this._tuiCallEngine.off(TUICallEvent.MESSAGE_SENT_BY_ME, this._messageSentByMe); | ||
// @ts-ignore | ||
TUICallEvent.ON_USER_NETWORK_QUALITY_CHANGED && this._tuiCallEngine.off(TUICallEvent.ON_USER_NETWORK_QUALITY_CHANGED, this._handleNetworkQuality, this); | ||
this._tuiCallEngine.off(TUICallEvent.CALL_END, this._handleCallingEnd); | ||
// @ts-ignore | ||
this._tuiCallEngine.off(TUICallEvent.CALL_MODE, this._handleCallTypeChange); // 切换通话事件 miniProgram CALL_MODE | ||
// @ts-ignore | ||
this._tuiCallEngine.off(TUICallEvent.USER_UPDATE, this._handleUserUpdate); // mini: user data update | ||
this._engineEventHandler.removeListenTuiCallEngineEvent(); | ||
} | ||
private _handleError(event: any): void { | ||
const { code, message } = event || {}; | ||
const index = Object.values(ErrorCode).indexOf(code); | ||
let callTips = ''; | ||
if (index !== -1) { | ||
const key = Object.keys(ErrorCode)[index]; | ||
callTips = t(ErrorMessage[key]); | ||
callTips && TUIStore.update(StoreName.CALL, NAME.TOAST_INFO, { text: callTips, type: NAME.ERROR }); | ||
} | ||
this._executeExternalAfterCalling(); | ||
console.error(`${NAME.PREFIX}_handleError, errorCode: ${code}; errorMessage: ${callTips || message}.`); | ||
} | ||
private async _handleNewInvitationReceived(event: any) { | ||
console.log(`${NAME.PREFIX}onCallReceived event data: ${JSON.stringify(event)}.`); | ||
const { sponsor = '', isFromGroup, callMediaType, inviteData = {}, calleeIdList = [], groupID = '', roomID, strRoomID } = this._analyzeEventData(event); | ||
const currentUserInfo: IUserInfo = TUIStore.getData(StoreName.CALL, NAME.LOCAL_USER_INFO); | ||
const remoteUserIdList: string[] = [sponsor, ...calleeIdList.filter((userId: string) => userId !== currentUserInfo.userId)]; | ||
const type = callMediaType || inviteData.callType; | ||
const callTipsKey = type === CallMediaType.AUDIO ? CallTips.CALLEE_CALLING_AUDIO_MSG : CallTips.CALLEE_CALLING_VIDEO_MSG; | ||
let updateStoreParams = { | ||
[NAME.CALL_ROLE]: CallRole.CALLEE, | ||
[NAME.IS_GROUP]: isFromGroup, | ||
[NAME.CALL_STATUS]: CallStatus.CALLING, | ||
[NAME.CALL_MEDIA_TYPE]: type, | ||
[NAME.CALL_TIPS]: t(callTipsKey), | ||
[NAME.CALLER_USER_INFO]: { userId: sponsor }, | ||
[NAME.GROUP_ID]: groupID, | ||
}; | ||
initAndCheckRunEnv(); | ||
const pusher = { enableCamera: type === CallMediaType.VIDEO, enableMic: true }; // mini 默认打开麦克风 | ||
updateStoreParams = { ...updateStoreParams, [NAME.PUSHER]: pusher }; | ||
updateRoomIdAndRoomIdType(TUIStore, roomID, strRoomID); | ||
TUIStore.updateStore(updateStoreParams, StoreName.CALL); | ||
this._executeExternalBeforeCalling(); | ||
this.statusChanged && this.statusChanged({ oldStatus: StatusChange.IDLE, newStatus: StatusChange.BE_INVITED }); | ||
const remoteUserInfoList = await getRemoteUserProfile(remoteUserIdList, this.getTim(), TUIStore); | ||
const [userInfo] = remoteUserInfoList.filter((userInfo: IUserInfo) => userInfo.userId === sponsor); | ||
remoteUserInfoList.length > 0 && TUIStore.updateStore({ | ||
[NAME.REMOTE_USER_INFO_LIST]: remoteUserInfoList, | ||
[NAME.REMOTE_USER_INFO_EXCLUDE_VOLUMN_LIST]: remoteUserInfoList, | ||
[NAME.CALLER_USER_INFO]: { | ||
userId: sponsor, | ||
nick: userInfo?.nick || '', | ||
avatar: userInfo?.avatar || '', | ||
displayUserInfo: userInfo?.remark || userInfo?.nick || sponsor, | ||
}, | ||
}, StoreName.CALL); | ||
} | ||
private _handleUserAccept(event: any): void { | ||
this._callerChangeToConnected(); | ||
TUIStore.update(StoreName.CALL, NAME.TOAST_INFO, t('answered')); | ||
console.log(`${NAME.PREFIX}accept event data: ${JSON.stringify(event)}.`); | ||
} | ||
private async _handleUserEnter(event: any): Promise<void> { | ||
this._callerChangeToConnected(); | ||
const { userID: userId, data } = this._analyzeEventData(event); | ||
data?.playerList && TUIStore.update(StoreName.CALL, NAME.PLAYER, data.playerList); | ||
let remoteUserInfoList = TUIStore.getData(StoreName.CALL, NAME.REMOTE_USER_INFO_LIST); | ||
const isInRemoteUserList = remoteUserInfoList.find(item => item?.userId === userId); | ||
if (!isInRemoteUserList) { | ||
remoteUserInfoList.push({ userId }); | ||
if (remoteUserInfoList.length > 0) { | ||
TUIStore.update(StoreName.CALL, NAME.REMOTE_USER_INFO_LIST, remoteUserInfoList); | ||
TUIStore.update(StoreName.CALL, NAME.REMOTE_USER_INFO_EXCLUDE_VOLUMN_LIST, remoteUserInfoList); | ||
} | ||
const [userInfo] = await getRemoteUserProfile([userId], this.getTim(), TUIStore); | ||
remoteUserInfoList = TUIStore.getData(StoreName.CALL, NAME.REMOTE_USER_INFO_LIST); | ||
remoteUserInfoList.forEach((obj) => { | ||
if (obj?.userId === userId) { | ||
obj = Object.assign(obj, userInfo); | ||
} | ||
}); | ||
} | ||
remoteUserInfoList = remoteUserInfoList.map((obj: IUserInfo) => { | ||
if (obj.userId === userId) obj.isEnter = true; | ||
return obj; | ||
}); | ||
if (remoteUserInfoList.length > 0) { | ||
TUIStore.update(StoreName.CALL, NAME.REMOTE_USER_INFO_LIST, remoteUserInfoList); | ||
TUIStore.update(StoreName.CALL, NAME.REMOTE_USER_INFO_EXCLUDE_VOLUMN_LIST, remoteUserInfoList); | ||
uiDesign.updateViewBackgroundUserId('remote'); | ||
} | ||
console.log(`${NAME.PREFIX}userEnter event data: ${JSON.stringify(event)}.`); | ||
} | ||
private _callerChangeToConnected() { | ||
const callRole = TUIStore.getData(StoreName.CALL, NAME.CALL_ROLE); | ||
const callStatus = TUIStore.getData(StoreName.CALL, NAME.CALL_STATUS); | ||
if (callStatus === CallStatus.CALLING && callRole === CallRole.CALLER) { | ||
TUIStore.update(StoreName.CALL, NAME.CALL_STATUS, CallStatus.CONNECTED); | ||
this._startTimer(); | ||
} | ||
} | ||
private _handleUserLeave(event: any): void { | ||
console.log(`${NAME.PREFIX}userLeave event data: ${JSON.stringify(event)}.`); | ||
const { data, userID: userId } = this._analyzeEventData(event); | ||
data?.playerList && TUIStore.update(StoreName.CALL, NAME.PLAYER, data.playerList); | ||
if (TUIStore.getData(StoreName.CALL, NAME.IS_GROUP)) { | ||
const remoteUserInfoList = TUIStore.getData(StoreName.CALL, NAME.REMOTE_USER_INFO_LIST); | ||
const prefix: string = (remoteUserInfoList.find(obj => obj.userId === userId) || {}).displayUserInfo || userId; | ||
const text = generateText(TUIStore, CallTips.END_CALL, prefix); | ||
TUIStore.update(StoreName.CALL, NAME.TOAST_INFO, { text }); | ||
} | ||
userId && this._deleteRemoteUser([userId]); | ||
} | ||
private _unNormalEventsManager(event: any, eventName: TUICallEvent): void { | ||
console.log(`${NAME.PREFIX}${eventName} event data: ${JSON.stringify(event)}.`); | ||
const isGroup = TUIStore.getData(StoreName.CALL, NAME.IS_GROUP); | ||
const remoteUserInfoList = TUIStore.getData(StoreName.CALL, NAME.REMOTE_USER_INFO_LIST); | ||
switch (eventName) { | ||
case TUICallEvent.REJECT: | ||
case TUICallEvent.LINE_BUSY: { | ||
const { userID: userId } = this._analyzeEventData(event); | ||
let callTipsKey = eventName === TUICallEvent.REJECT ? CallTips.OTHER_SIDE_REJECT_CALL : CallTips.OTHER_SIDE_LINE_BUSY; | ||
let text = generateText(TUIStore, callTipsKey); | ||
if (isGroup) { | ||
const prefix: string = (remoteUserInfoList.find(obj => obj.userId === userId) || {}).displayUserInfo || userId; | ||
callTipsKey = eventName === TUICallEvent.REJECT ? CallTips.REJECT_CALL : CallTips.IN_BUSY; | ||
text = generateText(TUIStore, callTipsKey, prefix); | ||
} | ||
TUIStore.update(StoreName.CALL, NAME.TOAST_INFO, { text }); | ||
userId && this._deleteRemoteUser([userId]); | ||
break; | ||
} | ||
case TUICallEvent.NO_RESP: { | ||
const { userIDList = [] } = this._analyzeEventData(event); | ||
const callTipsKey = isGroup ? CallTips.TIMEOUT : CallTips.CALL_TIMEOUT; | ||
const userInfoList: string[] = userIDList.map(userId => { | ||
const userInfo: IUserInfo = remoteUserInfoList.find(obj => obj.userId === userId) || {}; | ||
return userInfo.displayUserInfo || userId; | ||
}); | ||
const text = isGroup ? generateText(TUIStore, callTipsKey, userInfoList.join()) : generateText(TUIStore, callTipsKey); | ||
TUIStore.update(StoreName.CALL, NAME.TOAST_INFO, { text }); | ||
userIDList.length > 0 && this._deleteRemoteUser(userIDList); | ||
break; | ||
} | ||
case TUICallEvent.CALLING_CANCEL: { | ||
// TUIStore.update(StoreName.CALL, NAME.TOAST_INFO, { text: generateText(TUIStore, CallTips.CANCEL) }); | ||
this._resetCallStore(); | ||
break; | ||
} | ||
} | ||
} | ||
private _handleInviteeReject(event: any): void { | ||
this._unNormalEventsManager(event, TUICallEvent.REJECT); | ||
} | ||
private _handleNoResponse(event: any): void { | ||
this._unNormalEventsManager(event, TUICallEvent.NO_RESP); | ||
} | ||
private _handleLineBusy(event: any): void { | ||
this._unNormalEventsManager(event, TUICallEvent.LINE_BUSY); | ||
} | ||
private _handleCallingCancel(event: any): void { | ||
this._executeExternalAfterCalling(); | ||
this._unNormalEventsManager(event, TUICallEvent.CALLING_CANCEL); | ||
} | ||
private _handleCallingEnd(event: any): void { | ||
console.log(`${NAME.PREFIX}callEnd event data: ${JSON.stringify(event)}.`); | ||
this._executeExternalAfterCalling(); | ||
this._resetCallStore(); | ||
} | ||
// SDK_READY 后才能调用 tim 接口, 否则登录后立刻获取导致调用接口失败. v2.27.4+、v3 接口 login 后会抛出 SDK_READY | ||
private async _handleSDKReady(event: any): Promise<void> { | ||
let localUserInfo: IUserInfo = TUIStore.getData(StoreName.CALL, NAME.LOCAL_USER_INFO); | ||
localUserInfo = await getMyProfile(localUserInfo.userId, this.getTim(), TUIStore); | ||
this._defaultOfflinePushInfo.title = localUserInfo?.displayUserInfo; | ||
TUIStore.update(StoreName.CALL, NAME.LOCAL_USER_INFO, localUserInfo); | ||
TUIStore.update(StoreName.CALL, NAME.LOCAL_USER_INFO_EXCLUDE_VOLUMN, localUserInfo); | ||
} | ||
private _handleKickedOut(event: any): void { | ||
console.log(`${NAME.PREFIX}kickOut event data: ${JSON.stringify(event)}.`); | ||
this.kickedOut && this.kickedOut(event); | ||
TUIStore.update(StoreName.CALL, NAME.CALL_TIPS, generateText(TUIStore, CallTips.KICK_OUT)); | ||
this._resetCallStore(); | ||
} | ||
private _handleCallTypeChange(event: any): void { | ||
const { newCallType, type } = this._analyzeEventData(event); | ||
TUIStore.update(StoreName.CALL, NAME.CALL_MEDIA_TYPE, newCallType || type); | ||
this.setSoundMode(AudioPlayBackDevice.EAR); | ||
} | ||
private _messageSentByMe(event: any): void { | ||
const message = event?.data; | ||
this.onMessageSentByMe && this.onMessageSentByMe(message); | ||
} | ||
private _handleNetworkQuality(event) { | ||
const { networkQualityList = [] } = this._analyzeEventData(event); | ||
TUIStore.update(StoreName.CALL, NAME.NETWORK_STATUS, networkQualityList); | ||
const isGroup = TUIStore.getData(StoreName.CALL, NAME.IS_GROUP); | ||
const localUserInfo = TUIStore.getData(StoreName.CALL, NAME.LOCAL_USER_INFO); | ||
const remoteUserInfoList = TUIStore.getData(StoreName.CALL, NAME.REMOTE_USER_INFO_LIST); | ||
if(!isGroup) { | ||
const isRemoteNetworkPoor = networkQualityList.find(user => remoteUserInfoList[0]?.userId === user?.userId && user?.quality >= NETWORK_QUALITY_THRESHOLD); | ||
if(isRemoteNetworkPoor) { | ||
TUIStore.update(StoreName.CALL, NAME.CALL_TIPS, t(CallTips.THE_OTHER_USER_NETWORK_IS_POOR_DURING_THE_CURRENT_CALL)); | ||
return; | ||
}; | ||
const isLocalNetworkPoor = networkQualityList.find(user => localUserInfo?.userId === user?.userId && user?.quality >= NETWORK_QUALITY_THRESHOLD); | ||
if(isLocalNetworkPoor) { | ||
TUIStore.update(StoreName.CALL, NAME.CALL_TIPS, t(CallTips.THE_NETWORK_IS_POOR_DURING_YOUR_CURRENT_CALL)); | ||
return; | ||
} | ||
} | ||
} | ||
// ==========================【 miniProgram 私有事件】========================== | ||
private _handleUserUpdate(event: any): void { | ||
const data = this._analyzeEventData(event); | ||
data?.pusher && TUIStore.update(StoreName.CALL, NAME.PUSHER, data.pusher); | ||
data?.playerList && TUIStore.update(StoreName.CALL, NAME.PLAYER, data.playerList); | ||
} | ||
// 处理 “呼叫” 抛出的异常 | ||
private _handleCallError(error: any, methodName?: string) { | ||
if (handleRepeatedCallError(error)) return; | ||
handlePackageError(error); // 无套餐提示, 小程序 engine 不抛出 onError | ||
this._noDevicePermissionToast(error, CallMediaType.AUDIO); | ||
console.error(`${NAME.PREFIX}${methodName} failed, error: ${error}.`); | ||
this._resetCallStore(); | ||
throw error; | ||
} | ||
// ========================【原 Web CallKit 提供的方法】======================== | ||
@@ -792,3 +483,2 @@ public beforeCalling: ((...args: any[]) => void) | undefined; // 原来 | ||
} | ||
public toggleMinimize() { | ||
@@ -800,6 +490,6 @@ const isMinimized = TUIStore.getData(StoreName.CALL, NAME.IS_MINIMIZED); | ||
} | ||
private _executeExternalBeforeCalling(): void { | ||
public executeExternalBeforeCalling(): void { | ||
this.beforeCalling && this.beforeCalling(); | ||
} | ||
private _executeExternalAfterCalling(): void { | ||
public executeExternalAfterCalling(): void { | ||
this.afterCalling && this.afterCalling(); | ||
@@ -815,2 +505,3 @@ } | ||
} catch (error) { | ||
this._resetCallStore(); | ||
console.error(`${NAME.PREFIX} handleExceptionExit failed, error: ${error}.`); | ||
@@ -835,3 +526,3 @@ } | ||
TUIStore.update(StoreName.CALL, NAME.VIDEO_RESOLUTION, resolution); | ||
await this._tuiCallEngine.setVideoQuality(resolution); | ||
await this._tuiCallEngine?.setVideoQuality(resolution); | ||
} catch (error) { | ||
@@ -841,13 +532,19 @@ console.warn(`${NAME.PREFIX}setVideoResolution failed, error: ${error}.`); | ||
} | ||
private _setLocalUserInfoAudioVideoAvailable(isAvailable: boolean, type: string) { | ||
let localUserInfo = TUIStore.getData(StoreName.CALL, NAME.LOCAL_USER_INFO); | ||
if (type === NAME.AUDIO) { | ||
localUserInfo = { ...localUserInfo, isAudioAvailable: isAvailable }; | ||
// 通话时长更新 | ||
public startTimer(): void { | ||
if (this._timerId === -1) { | ||
this._startTimeStamp = performanceNow(); | ||
this._timerId = timer.run(NAME.TIMEOUT, this._updateCallDuration.bind(this), { delay: 1000 }); | ||
} | ||
if (type === NAME.VIDEO) { | ||
localUserInfo = { ...localUserInfo, isVideoAvailable: isAvailable }; | ||
} | ||
TUIStore.update(StoreName.CALL, NAME.LOCAL_USER_INFO, localUserInfo); | ||
TUIStore.update(StoreName.CALL, NAME.LOCAL_USER_INFO_EXCLUDE_VOLUMN, localUserInfo); | ||
} | ||
// =========================【private methods for service use】========================= | ||
// 处理 “呼叫” 抛出的异常 | ||
private _handleCallError(error: any, methodName?: string) { | ||
if (handleRepeatedCallError(error)) return; | ||
handlePackageError(error); // 无套餐提示, 小程序 engine 不抛出 onError | ||
noDevicePermissionToast(error, CallMediaType.AUDIO, this._tuiCallEngine); | ||
console.error(`${NAME.PREFIX}${methodName} failed, error: ${error}.`); | ||
this._resetCallStore(); | ||
throw error; | ||
} | ||
private async _updateCallStoreBeforeCall(type: number, remoteUserInfoList: IUserInfo[], groupID?: string): Promise<void> { | ||
@@ -870,3 +567,3 @@ const callTips = groupID || TUIStore.getData(StoreName.CALL, NAME.IS_MINIMIZED) ? CallTips.CALLER_GROUP_CALLING_MSG : CallTips.CALLER_CALLING_MSG; | ||
TUIStore.update(StoreName.CALL, NAME.CALL_STATUS, callStatus); | ||
const remoteUserInfoLists = await getRemoteUserProfile(remoteUserInfoList.map(obj => obj.userId), this.getTim(), TUIStore); | ||
const remoteUserInfoLists = await getRemoteUserProfile(remoteUserInfoList.map(obj => obj.userId), this.getTim()); | ||
@@ -881,9 +578,9 @@ if (remoteUserInfoLists.length > 0) { | ||
TUIStore.update(StoreName.CALL, NAME.IS_CLICKABLE, true); | ||
updateRoomIdAndRoomIdType(TUIStore, response?.roomID, response?.strRoomID); | ||
updateRoomIdAndRoomIdType(response?.roomID, response?.strRoomID); | ||
const callMediaType = TUIStore.getData(StoreName.CALL, NAME.CALL_MEDIA_TYPE); | ||
this._callTUIService({ message: response?.data?.message }); | ||
this._chatCombine?.callTUIService({ message: response?.data?.message }); | ||
response.pusher && TUIStore.update(StoreName.CALL, NAME.PUSHER, response.pusher); | ||
this.setSoundMode(callMediaType === CallMediaType.AUDIO ? AudioPlayBackDevice.EAR : AudioPlayBackDevice.SPEAKER); | ||
TUIStore.update(StoreName.CALL, NAME.CALL_STATUS, CallStatus.CALLING); // 小程序未授权时, 此时状态为 idle; web 直接设置为 calling | ||
const isCameraDefaultStateClose = this.getFeatureButtonDefaultState(FeatureButton.Camera) === ButtonState.Close; | ||
const isCameraDefaultStateClose = this._getFeatureButtonDefaultState(FeatureButton.Camera) === ButtonState.Close; | ||
(callMediaType === CallMediaType.VIDEO) && !isCameraDefaultStateClose && await this.openCamera(NAME.LOCAL_VIDEO); | ||
@@ -893,3 +590,3 @@ const localUserInfo = TUIStore.getData(StoreName.CALL, NAME.LOCAL_USER_INFO); | ||
TUIStore.update(StoreName.CALL, NAME.LOCAL_USER_INFO_EXCLUDE_VOLUMN, { ...localUserInfo, isEnter: true }); | ||
this._setLocalUserInfoAudioVideoAvailable(true, NAME.AUDIO); // web && mini, default open audio | ||
setLocalUserInfoAudioVideoAvailable(true, NAME.AUDIO); // web && mini, default open audio | ||
} else { | ||
@@ -899,4 +596,19 @@ this._resetCallStore(); | ||
} | ||
private _getFeatureButtonDefaultState(buttonName: FeatureButton) { | ||
const { button: buttonConfig } = TUIStore.getData(StoreName.CALL, NAME.CUSTOM_UI_CONFIG); | ||
return buttonConfig?.[buttonName]?.state; | ||
} | ||
private _updateCallDuration(): void { | ||
const callDurationNum = Math.round((performanceNow() - this._startTimeStamp) / 1000); // miniProgram stop timer when background | ||
const callDurationStr = formatTime(callDurationNum); | ||
TUIStore.update(StoreName.CALL, NAME.CALL_DURATION, callDurationStr); | ||
} | ||
private _stopTimer(): void { | ||
if (this._timerId !== -1) { | ||
timer.clearTask(this._timerId); | ||
this._timerId = -1; | ||
} | ||
} | ||
private _resetCallStore() { | ||
const oldStatusStr = generateStatusChangeText(TUIStore); | ||
const oldStatusStr = generateStatusChangeText(); | ||
this._stopTimer(); | ||
@@ -945,3 +657,3 @@ // localUserInfo, language 在通话结束后不需要清除 | ||
TUIStore.update(StoreName.CALL, NAME.REMOTE_USER_INFO_EXCLUDE_VOLUMN_LIST, []); | ||
const newStatusStr = generateStatusChangeText(TUIStore); | ||
const newStatusStr = generateStatusChangeText(); | ||
if (oldStatusStr !== newStatusStr) { | ||
@@ -951,69 +663,2 @@ this.statusChanged && this.statusChanged({ oldStatus: oldStatusStr, newStatus: newStatusStr }); | ||
} | ||
private _noDevicePermissionToast(error: any, type: CallMediaType): void { | ||
if (handleNoDevicePermissionError(error)) { | ||
let text = ''; | ||
if (type === CallMediaType.AUDIO) { | ||
text = generateText(TUIStore, CallTips.NO_MICROPHONE_DEVICE_PERMISSION); | ||
} | ||
if (type === CallMediaType.VIDEO) { | ||
text = generateText(TUIStore, CallTips.NO_CAMERA_DEVICE_PERMISSION); | ||
} | ||
text && TUIStore.update(StoreName.CALL, NAME.TOAST_INFO, { text, type: NAME.ERROR }); | ||
console.error(`${NAME.PREFIX}call failed, error: ${error.message}.`); | ||
} | ||
} | ||
// 通话时长更新 | ||
private _startTimer(): void { | ||
if (this._timerId === -1) { | ||
this._startTimeStamp = performanceNow(); | ||
this._timerId = timer.run(NAME.TIMEOUT, this._updateCallDuration.bind(this), { delay: 1000 }); | ||
} | ||
} | ||
private _updateCallDuration(): void { | ||
const callDurationNum = Math.round((performanceNow() - this._startTimeStamp) / 1000); // miniProgram stop timer when background | ||
const callDurationStr = formatTime(callDurationNum); | ||
TUIStore.update(StoreName.CALL, NAME.CALL_DURATION, callDurationStr); | ||
} | ||
private _stopTimer(): void { | ||
if (this._timerId !== -1) { | ||
timer.clearTask(this._timerId); | ||
this._timerId = -1; | ||
} | ||
} | ||
private _deleteRemoteUser(userIdList: string[]): void { | ||
if (userIdList.length === 0) return; | ||
let remoteUserInfoList = TUIStore.getData(StoreName.CALL, NAME.REMOTE_USER_INFO_LIST); | ||
userIdList.forEach((userId) => { | ||
remoteUserInfoList = remoteUserInfoList.filter((obj: IUserInfo) => obj.userId !== userId); | ||
}); | ||
TUIStore.update(StoreName.CALL, NAME.REMOTE_USER_INFO_LIST, remoteUserInfoList); | ||
TUIStore.update(StoreName.CALL, NAME.REMOTE_USER_INFO_EXCLUDE_VOLUMN_LIST, remoteUserInfoList); | ||
} | ||
private _analyzeEventData(event: any): any { | ||
return event?.data || {}; // mini INVITED | ||
} | ||
// =========================【chat: event listening】========================= | ||
private _addListenChatEvent() { | ||
if (!this._tim) { | ||
console.warn(`${NAME.PREFIX}add tim event listener failed, tim is empty.`); | ||
return; | ||
} | ||
this._tim.on(TencentCloudChat.EVENT.GROUP_ATTRIBUTES_UPDATED, this._handleGroupAttributesUpdated, this); | ||
} | ||
private _removeListenChatEvent() { | ||
if (!this._tim) { | ||
console.warn(`${NAME.PREFIX}remove tim event listener failed, tim is empty.`); | ||
return; | ||
} | ||
this._tim.off(TencentCloudChat.EVENT.GROUP_ATTRIBUTES_UPDATED, this._handleGroupAttributesUpdated, this); | ||
} | ||
private async _handleGroupAttributesUpdated(event) { | ||
if (TUIStore.getData(StoreName.CALL, NAME.CALL_STATUS) !== CallStatus.IDLE) return; | ||
const data = event?.data || {}; | ||
const { groupID: groupId = '', groupAttributes = {} } = data; | ||
if (groupId !== this._currentGroupId) return; | ||
await updateStoreBasedOnGroupAttributes(groupAttributes, TUIStore, this); | ||
} | ||
// =========================【Calling the Chat SDK APi】========================= | ||
@@ -1031,7 +676,3 @@ // 获取群成员 | ||
} | ||
public getFeatureButtonDefaultState(buttonName: FeatureButton) { | ||
const { button: buttonConfig } = TUIStore.getData(StoreName.CALL, NAME.CUSTOM_UI_CONFIG); | ||
return buttonConfig?.[buttonName]?.state; | ||
} | ||
// =========================【监听 TUIStore 中的状态】========================= | ||
// =========================【监听 TUIStore 中的状态及处理】========================= | ||
private _handleCallStatusChange = async (value: CallStatus) => { | ||
@@ -1054,3 +695,3 @@ try { | ||
TUIStore.update(StoreName.CALL, NAME.CALL_TIPS, ''); | ||
this.statusChanged && this.statusChanged({ oldStatus, newStatus: generateStatusChangeText(TUIStore) }); | ||
this.statusChanged && this.statusChanged({ oldStatus, newStatus: generateStatusChangeText() }); | ||
if (!isGroup && callMediaType === CallMediaType.VIDEO) { | ||
@@ -1062,4 +703,4 @@ this.switchScreen(remoteUserInfoList[0].domId); | ||
if (this._isFromChat) { | ||
const groupAttributes = this._currentGroupId ? await getGroupAttributes(this._tim, this._currentGroupId) : {}; | ||
await updateStoreBasedOnGroupAttributes(groupAttributes, TUIStore, this); | ||
const groupAttributes = this._currentGroupId ? await this._chatCombine?.getGroupAttributes(this._tim, this._currentGroupId) : {}; | ||
await this._chatCombine?.updateStoreBasedOnGroupAttributes(groupAttributes, TUIStore, this); | ||
} | ||
@@ -1083,102 +724,39 @@ } | ||
} | ||
// =========================【web 融合 chat 提供的方法】========================= | ||
// =========================【融合 chat 】========================= | ||
public bindTUICore(TUICore: any) { | ||
this._TUICore = TUICore; | ||
} | ||
// 下面方法用于接入 TUICore | ||
private _callTUIService(params) { | ||
const { message } = params || {}; | ||
TUICore.callService({ | ||
serviceName: TUIConstants.TUIChat.SERVICE.NAME, | ||
method: TUIConstants.TUIChat.SERVICE.METHOD.UPDATE_MESSAGE_LIST, | ||
params: { message }, | ||
}); | ||
} | ||
public async onNotifyEvent(eventName: string, subKey: string, options?: any) { | ||
try { | ||
if (eventName === TUIConstants.TUILogin.EVENT.LOGIN_STATE_CHANGED) { | ||
if (subKey === TUIConstants.TUILogin.EVENT_SUB_KEY.USER_LOGIN_SUCCESS) { | ||
// TUICallkit 收到登录成功时执行自己的业务逻辑处理 | ||
// @ts-ignore | ||
const { chat, userID, userSig, SDKAppID } = TUILogin.getContext(); | ||
await this.init({ tim: chat, userID, userSig, sdkAppID: SDKAppID, isFromChat: true, component: COMPONENT.TIM_CALL_KIT }); | ||
this._isFromChat = true; | ||
this.setLogLevel(LOG_LEVEL.NORMAL); | ||
this._addListenChatEvent(); | ||
} else if (subKey === TUIConstants.TUILogin.EVENT_SUB_KEY.USER_LOGOUT_SUCCESS) { | ||
this._removeListenChatEvent(); | ||
await this.destroyed(); | ||
} | ||
} | ||
// @ts-ignore | ||
if (TUIConstants.TUIChat?.EVENT && eventName === TUIConstants.TUIChat.EVENT.CHAT_STATE_CHANGED) { | ||
// @ts-ignore | ||
if (subKey === TUIConstants.TUIChat.EVENT_SUB_KEY.CHAT_OPENED) { | ||
this._currentGroupId = options?.groupID || ''; | ||
if (TUIStore.getData(StoreName.CALL, NAME.CALL_STATUS) !== CallStatus.IDLE) return; | ||
const groupAttributes = this._currentGroupId ? await getGroupAttributes(this._tim, this._currentGroupId) : {}; | ||
await updateStoreBasedOnGroupAttributes(groupAttributes, TUIStore, this); | ||
} | ||
} | ||
} catch (error) { | ||
console.error(`${NAME.PREFIX}TUICore onNotifyEvent failed, error: ${error}.`); | ||
} | ||
await this._chatCombine?.onTUICoreNotifyEvent(eventName, subKey, options); | ||
} | ||
public async onCall(method: String, params: any) { | ||
if (method === TUIConstants.TUICalling.SERVICE.METHOD.START_CALL) { | ||
await this._handleTUICoreOnClick(params, params.type); | ||
} | ||
await this._chatCombine?.onCall(method, params); | ||
} | ||
private async _handleTUICoreOnClick(options, type: CallMediaType) { | ||
try { | ||
const { groupID, userIDList = [], ...rest } = options; | ||
if (groupID) { | ||
await this.groupCall({ groupID, userIDList, type, ...rest }); | ||
} else if (userIDList.length === 1) { | ||
await this.call({ userID: userIDList[0], type, ...rest }); | ||
} | ||
} catch (error: any) { | ||
console.debug(error); | ||
} | ||
public onGetExtension(extensionID: string, params: any) { | ||
return this._chatCombine?.onGetExtensionTUICore(extensionID, params); | ||
} | ||
public onGetExtension(extensionID: string, params: any) { | ||
if (extensionID === TUIConstants.TUIChat.EXTENSION.INPUT_MORE.EXT_ID) { | ||
this._tuiCallEngine?.reportLog?.({ name: 'TUICallKit.onGetExtension', data: { extensionID, params } }); | ||
if (isUndefined(params)) return []; | ||
// room and customer_service ChatType not show audio and video icon. | ||
if ([TUIConstants.TUIChat.TYPE.ROOM, TUIConstants.TUIChat.TYPE.CUSTOMER_SERVICE].includes(params.chatType)) return []; | ||
let list = []; | ||
const audioCallExtension: ExtensionInfo = { | ||
weight: 1000, | ||
text: '语音通话', | ||
icon: AudioCallIcon, | ||
data: { | ||
name: 'voiceCall', | ||
}, | ||
listener: { | ||
onClicked: async options => await this._handleTUICoreOnClick(options, options.type || CallMediaType.AUDIO), // 点击时发起通话 | ||
}, | ||
}; | ||
const videoCallExtension: ExtensionInfo = { | ||
weight: 900, | ||
text: '视频通话', | ||
icon: VideoCallIcon, | ||
data: { | ||
name: 'videoCall', | ||
}, | ||
listener: { | ||
onClicked: async options => await this._handleTUICoreOnClick(options, options.type || CallMediaType.VIDEO), // 点击时发起通话 | ||
}, | ||
}; | ||
if (params?.chatType) { | ||
list = [audioCallExtension, videoCallExtension]; | ||
} else { | ||
!params?.filterVoice && list.push(audioCallExtension); | ||
!params?.filterVideo && list.push(videoCallExtension); | ||
} | ||
return list; | ||
// =========================【set、get methods】========================= | ||
public getTim() { | ||
if (this._tim) return this._tim; | ||
if (!this._tuiCallEngine) { | ||
console.warn(`${NAME.PREFIX}getTim warning: _tuiCallEngine Instance is not available.`); | ||
return null; | ||
} | ||
return this._tuiCallEngine?.tim || this._tuiCallEngine?.getTim(); // mini support getTim interface | ||
} | ||
} | ||
public setIsFromChat(isFromChat: boolean) { | ||
this._isFromChat = isFromChat; | ||
} | ||
public setCurrentGroupId(groupId: string) { | ||
this._currentGroupId = groupId; | ||
} | ||
public getCurrentGroupId() { | ||
return this._currentGroupId; | ||
} | ||
public setDefaultOfflinePushInfo(offlinePushInfo) { | ||
this._defaultOfflinePushInfo = offlinePushInfo; | ||
} | ||
public getDefaultOfflinePushInfo() { | ||
return this._defaultOfflinePushInfo; | ||
} | ||
} |
@@ -1,5 +0,9 @@ | ||
import { NAME, StoreName, CallStatus, StatusChange, CallMediaType, CallType, ROOM_ID_TYPE } from '../const/index'; | ||
import { NAME, StoreName, CallStatus, StatusChange, CallMediaType, ROOM_ID_TYPE } from '../const/index'; | ||
import { handleNoDevicePermissionError } from '../utils/common-utils'; | ||
import { IUserInfo } from '../interface/ICallService'; | ||
import { ITUIStore } from '../interface/ITUIStore'; | ||
import { t } from '../locales/index'; | ||
import { CallTips, t } from '../locales/index'; | ||
import TuiStore from '../TUIStore/tuiStore'; | ||
// @ts-ignore | ||
const TUIStore: ITUIStore = TuiStore.getInstance(); | ||
@@ -22,3 +26,3 @@ // 设置默认的 UserInfo 信息 | ||
// 获取个人用户信息 | ||
export async function getMyProfile(myselfUserId: string, tim: any, TUIStore: any): Promise<IUserInfo> { | ||
export async function getMyProfile(myselfUserId: string, tim: any): Promise<IUserInfo> { | ||
let localUserInfo: IUserInfo = setDefaultUserInfo(myselfUserId, NAME.LOCAL_VIDEO); | ||
@@ -46,3 +50,3 @@ try { | ||
// 获取远端用户列表信息 | ||
export async function getRemoteUserProfile(userIdList: Array<string>, tim: any, TUIStore: any): Promise<any> { | ||
export async function getRemoteUserProfile(userIdList: Array<string>, tim: any): Promise<any> { | ||
let remoteUserInfoList: IUserInfo[] = userIdList.map((userId: string) => setDefaultUserInfo(userId)); | ||
@@ -94,3 +98,3 @@ try { | ||
// 生成弹框提示文案 | ||
export function generateText(TUIStore: ITUIStore, key: string, prefix?: string, suffix?: string): string { | ||
export function generateText(key: string, prefix?: string, suffix?: string): string { | ||
const isGroup = TUIStore.getData(StoreName.CALL, NAME.IS_GROUP); | ||
@@ -105,3 +109,3 @@ let callTips = `${t(key)}`; | ||
// 生成 statusChange 抛出的字符串 | ||
export function generateStatusChangeText(TUIStore: ITUIStore): string { | ||
export function generateStatusChangeText(): string { | ||
const callStatus = TUIStore.getData(StoreName.CALL, NAME.CALL_STATUS); | ||
@@ -145,52 +149,8 @@ if (callStatus === CallStatus.IDLE) { | ||
} | ||
// Get group attribute | ||
export async function getGroupAttributes(tim: any, groupId: string) { | ||
if (!groupId) return {}; | ||
try { | ||
const { data } = await tim.getGroupAttributes({ | ||
groupID: groupId, | ||
keyList: [] | ||
}); | ||
return data?.groupAttributes || {}; | ||
} catch (error) { | ||
console.warn(`${NAME.PREFIX}getGroupAttributes fail: ${error}`); | ||
return {}; | ||
} | ||
} | ||
// Handling the chat+call scenario, data required for the joinInGroupCall API: update store / clear relevant store data | ||
export async function updateStoreBasedOnGroupAttributes(groupAttributes: any, TUIStore: ITUIStore, that: any) { | ||
that._tuiCallEngine?.reportLog?.({ | ||
name: 'TUICallKit.getJoinGroupCallInfo.success', | ||
data: { groupAttributes }, | ||
}); | ||
try { | ||
const { | ||
group_id: groupId = '', | ||
room_id: roomId = 0, | ||
room_id_type: roomIdType = 0, | ||
call_media_type: callType = NAME.UNKNOWN, | ||
// @ts-ignore | ||
user_list: userList, // The default value of the user list returned by the background is null | ||
} = groupAttributes[NAME.INNER_ATTR_KIT_INFO] ? JSON.parse(groupAttributes[NAME.INNER_ATTR_KIT_INFO]) : {}; | ||
let userListInfo = (userList || []).map(user => user.userid); | ||
userListInfo = userListInfo.length && await getRemoteUserProfile(userListInfo, that._tim, TUIStore); | ||
const updateStoreParams = { | ||
[NAME.GROUP_ID]: groupId, | ||
[NAME.GROUP_CALL_MEMBERS]: userListInfo, | ||
[NAME.ROOM_ID]: roomId, | ||
[NAME.CALL_MEDIA_TYPE]: CallType[callType], | ||
[NAME.ROOM_ID_TYPE]: roomIdType, | ||
}; | ||
TUIStore.updateStore(updateStoreParams, StoreName.CALL); | ||
} catch (error) { | ||
console.warn(`${NAME.PREFIX}updateStoreBasedOnGroupAttributes fail, error: ${error}`); | ||
} | ||
} | ||
/** | ||
* update roomId and roomIdType | ||
* @param {ITUIStore} TUIStore TUIStore instance | ||
* @param {number} roomId number roomId | ||
* @param {string} strRoomId string roomId | ||
*/ | ||
export function updateRoomIdAndRoomIdType(TUIStore: ITUIStore, roomId, strRoomId) { | ||
export function updateRoomIdAndRoomIdType(roomId, strRoomId) { | ||
if (roomId === 0 && strRoomId) { // use strRoomID | ||
@@ -204,1 +164,99 @@ TUIStore.update(StoreName.CALL, NAME.ROOM_ID, strRoomId); | ||
} | ||
/** | ||
* web and miniProgram call engine throw event data structure are different | ||
* @param {any} event call engine throw out data | ||
* @returns {any} data | ||
*/ | ||
export function analyzeEventData(event: any): any { | ||
return event?.data || {}; // mini INVITED | ||
} | ||
/** | ||
* delete user from remoteUserInfoList | ||
* @param {string[]} userIdList to be deleted userIdList | ||
* @param {ITUIStore} TUIStore TUIStore instance | ||
*/ | ||
export function deleteRemoteUser(userIdList: string[]): void { | ||
if (userIdList.length === 0) return; | ||
let remoteUserInfoList = TUIStore.getData(StoreName.CALL, NAME.REMOTE_USER_INFO_LIST); | ||
userIdList.forEach((userId) => { | ||
remoteUserInfoList = remoteUserInfoList.filter((obj: IUserInfo) => obj.userId !== userId); | ||
}); | ||
TUIStore.update(StoreName.CALL, NAME.REMOTE_USER_INFO_LIST, remoteUserInfoList); | ||
TUIStore.update(StoreName.CALL, NAME.REMOTE_USER_INFO_EXCLUDE_VOLUMN_LIST, remoteUserInfoList); | ||
} | ||
export function updateDeviceList(tuiCallEngine) { | ||
tuiCallEngine?.getDeviceList('speaker').then((result)=>{ | ||
const deviceList = TUIStore.getData(StoreName.CALL, NAME.DEVICE_LIST); | ||
const currentSpeaker = result?.[0] || {}; | ||
TUIStore.update( | ||
StoreName.CALL, | ||
NAME.DEVICE_LIST, | ||
{ ...deviceList, speakerList: result, currentSpeaker }, | ||
); | ||
}).catch(error =>{ | ||
console.error(`${NAME.PREFIX}updateSpeakerList failed, error: ${JSON.stringify(error)}.`); | ||
}); | ||
const callMediaType = TUIStore.getData(StoreName.CALL, NAME.CALL_MEDIA_TYPE); | ||
if (callMediaType === CallMediaType.VIDEO) { | ||
tuiCallEngine?.getDeviceList('camera').then((result) => { | ||
const deviceList = TUIStore.getData(StoreName.CALL, NAME.DEVICE_LIST); | ||
const currentCamera = result?.[0] || {}; | ||
TUIStore.update( | ||
StoreName.CALL, | ||
NAME.DEVICE_LIST, | ||
{ ...deviceList, cameraList: result, currentCamera }, | ||
); | ||
}).catch(error => { | ||
console.error(`${NAME.PREFIX}updateCameraList failed, error: ${error}.`); | ||
}); | ||
} | ||
tuiCallEngine?.getDeviceList('microphones').then((result) => { | ||
const deviceList = TUIStore.getData(StoreName.CALL, NAME.DEVICE_LIST); | ||
const currentMicrophone = result?.[0] || {}; | ||
TUIStore.update( | ||
StoreName.CALL, | ||
NAME.DEVICE_LIST, | ||
{ ...deviceList, microphoneList: result, currentMicrophone }, | ||
); | ||
}).catch(error => { | ||
console.error(`${NAME.PREFIX}updateMicrophoneList failed, error: ${error}.`); | ||
}); | ||
} | ||
/** | ||
* update the no device permission toast | ||
* @param {any} error error | ||
* @param {CallMediaType} type call midia type | ||
* @param {any} tuiCallEngine TUICallEngine instance | ||
*/ | ||
export function noDevicePermissionToast(error, type: CallMediaType, tuiCallEngine: any) { | ||
if (handleNoDevicePermissionError(error)) { | ||
let text = ''; | ||
if (type === CallMediaType.AUDIO) { | ||
text = generateText(CallTips.NO_MICROPHONE_DEVICE_PERMISSION); | ||
} | ||
if (type === CallMediaType.VIDEO) { | ||
text = generateText(CallTips.NO_CAMERA_DEVICE_PERMISSION); | ||
} | ||
text && TUIStore.update(StoreName.CALL, NAME.TOAST_INFO, { text, type: NAME.ERROR }); | ||
console.error(`${NAME.PREFIX}call failed, error: ${error.message}.`); | ||
} | ||
} | ||
/** | ||
* set localUserInfo audio/video available | ||
* @param {boolean} isAvailable is available | ||
* @param {string} type callMediaType 'audio' | 'video' | ||
* @param {ITUIStore} TUIStore TUIStore instance | ||
*/ | ||
export function setLocalUserInfoAudioVideoAvailable(isAvailable: boolean, type: string) { | ||
let localUserInfo = TUIStore.getData(StoreName.CALL, NAME.LOCAL_USER_INFO); | ||
if (type === NAME.AUDIO) { | ||
localUserInfo = { ...localUserInfo, isAudioAvailable: isAvailable }; | ||
} | ||
if (type === NAME.VIDEO) { | ||
localUserInfo = { ...localUserInfo, isVideoAvailable: isAvailable }; | ||
} | ||
TUIStore.update(StoreName.CALL, NAME.LOCAL_USER_INFO, localUserInfo); | ||
TUIStore.update(StoreName.CALL, NAME.LOCAL_USER_INFO_EXCLUDE_VOLUMN, localUserInfo); | ||
} |
@@ -66,2 +66,4 @@ export const en = { | ||
"The other user network is poor during the current call": "The other party's network is poor during the current call", | ||
// eslint-disable-next-line max-len | ||
"TUICallKit initialization login is not complete. You need to use this API after the init API is finished.": "TUICallKit initialization login is not complete. You need to use this API after the init API is finished.", | ||
// 待废弃文案 | ||
@@ -68,0 +70,0 @@ 'Those involved': 'Those involved in the call are', |
@@ -60,2 +60,4 @@ export const ja_JP = { | ||
"The other user network is poor during the current call": "現在の通話で、相手側のネットワークが不良です", | ||
// eslint-disable-next-line max-len | ||
"TUICallKit initialization login is not complete. You need to use this API after the init API is finished.": "TUICallKitの初期化ログインが完了していません。init が完了した後にこのAPIを使用する必要があります。", | ||
// 待废弃文案 | ||
@@ -62,0 +64,0 @@ 'timeout': 'タイムアウト', |
@@ -66,2 +66,3 @@ export const zh = { | ||
"The other user network is poor during the current call": "当前通话对方网络不佳", | ||
"TUICallKit initialization login is not complete. You need to use this API after the init API is finished.": "TUICallKit 初始化登录未完成,需要在 init 完成后使用此 API", | ||
// 待废弃文案 | ||
@@ -68,0 +69,0 @@ 'timeout': '超时', |
import { avoidRepeatedCall } from './avoidRepeatedCall'; | ||
import { paramValidate } from './validateParams'; | ||
import { VALIDATE_PARAMS } from './validateConfig'; | ||
import { statusValidate } from './validateStatus'; | ||
// import { apiCallQueue } from "./apiCallQueue"; | ||
@@ -10,3 +11,4 @@ | ||
avoidRepeatedCall, | ||
statusValidate, | ||
// apiCallQueue, | ||
}; |
@@ -42,10 +42,10 @@ export declare const MessageProps: { | ||
export declare function useMessage(props: any, emits: any): { | ||
messageContent: import("@vue/reactivity").Ref<any>; | ||
messageDuration: import("@vue/reactivity").Ref<any>; | ||
messageType: import("@vue/reactivity").Ref<any>; | ||
messageOffset: import("@vue/reactivity").Ref<any>; | ||
isShowCloseIcon: import("@vue/reactivity").Ref<any>; | ||
visible: import("@vue/reactivity").Ref<boolean>; | ||
messageContent: import("@vue/reactivity").Ref<any, any>; | ||
messageDuration: import("@vue/reactivity").Ref<any, any>; | ||
messageType: import("@vue/reactivity").Ref<any, any>; | ||
messageOffset: import("@vue/reactivity").Ref<any, any>; | ||
isShowCloseIcon: import("@vue/reactivity").Ref<any, any>; | ||
visible: import("@vue/reactivity").Ref<boolean, boolean>; | ||
show: (messageObj?: any) => void; | ||
close: () => void; | ||
}; |
import { Ref } from '../../../../../adapter-vue'; | ||
export declare const useBtnConfig: (type: string, state: Ref<string>) => Ref<any>; | ||
export declare const useBtnConfig: (type: string, state: Ref<string>) => Ref<any, any>; |
@@ -57,3 +57,3 @@ export declare const VirtualBackgroundMobileConfig: { | ||
}; | ||
props?: undefined; | ||
props: {}; | ||
} | { | ||
@@ -66,10 +66,3 @@ name: string; | ||
props?: undefined; | ||
} | { | ||
name: string; | ||
customStyle: { | ||
justifyContent: string; | ||
paddingTop: string; | ||
}; | ||
props: {}; | ||
})[])[]; | ||
}; |
export declare function useButtonPanelLayout(): { | ||
readonly layout: import("@vue/reactivity").Ref<any[]>; | ||
readonly config: import("@vue/reactivity").Ref<any[]>; | ||
readonly layout: import("@vue/reactivity").Ref<any[], any[]>; | ||
readonly config: import("@vue/reactivity").Ref<any[], any[]>; | ||
}; |
@@ -5,4 +5,4 @@ import { Direction } from '.'; | ||
}): { | ||
currentIndex: import("@vue/reactivity").Ref<number>; | ||
direction: import("@vue/reactivity").Ref<Direction>; | ||
currentIndex: import("@vue/reactivity").Ref<number, number>; | ||
direction: import("@vue/reactivity").Ref<Direction, Direction>; | ||
}; |
import { ViewName } from '../../../../TUICallService/const'; | ||
export declare function useGetLargeViewName(): import("@vue/reactivity").Ref<ViewName>; | ||
export declare function useGetLargeViewName(): import("@vue/reactivity").Ref<ViewName, ViewName>; |
export declare function useCallDuration(): { | ||
callDuration: import("@vue/reactivity").Ref<any>; | ||
callDuration: import("@vue/reactivity").Ref<any, any>; | ||
}; |
import { ICustomUIConfig } from "../../TUICallService/const"; | ||
import { Ref } from "../../adapter-vue"; | ||
export declare function useCustomUI(): Ref<ICustomUIConfig>; | ||
export declare function useCustomUI(): Ref<ICustomUIConfig, ICustomUIConfig>; |
@@ -1,1 +0,1 @@ | ||
export declare function useCustomUIButtonConfig(): import("@vue/reactivity").Ref<any[]>; | ||
export declare function useCustomUIButtonConfig(): import("@vue/reactivity").Ref<any[], any[]>; |
import { DeviceType } from '../../TUICallService/const'; | ||
export declare function useDeviceList(deviceType: DeviceType): readonly [{ | ||
readonly deviceList: import("@vue/reactivity").Ref<any[]>; | ||
readonly currentDeviceId: import("@vue/reactivity").Ref<string>; | ||
readonly deviceList: import("@vue/reactivity").Ref<any[], any[]>; | ||
readonly currentDeviceId: import("@vue/reactivity").Ref<string, string>; | ||
}, { | ||
readonly updateCurrentDeviceId: (value: any) => void; | ||
}]; |
@@ -1,1 +0,1 @@ | ||
export declare function useFocusContext(): import("@vue/reactivity").Ref<string>; | ||
export declare function useFocusContext(): import("@vue/reactivity").Ref<string, string>; |
@@ -1,1 +0,1 @@ | ||
export declare function useGetVolumeMap(): import("@vue/reactivity").Ref<any>; | ||
export declare function useGetVolumeMap(): import("@vue/reactivity").Ref<any, any>; |
@@ -1,1 +0,1 @@ | ||
export declare function useGroupCallLayout(focus: any, length: any): import("@vue/reactivity").Ref<any>; | ||
export declare function useGroupCallLayout(focus: any, length: any): import("@vue/reactivity").Ref<any, any>; |
import { Ref } from '../../adapter-vue'; | ||
export declare function useIsClickableContext(): Ref<boolean>; | ||
export declare function useIsClickableContext(): Ref<boolean, boolean>; |
export declare function useJoinGroupCall(): { | ||
roomId: import("@vue/reactivity").Ref<any>; | ||
roomIdType: import("@vue/reactivity").Ref<any>; | ||
groupId: import("@vue/reactivity").Ref<any>; | ||
callMediaType: import("@vue/reactivity").Ref<any>; | ||
groupCallMembers: import("@vue/reactivity").Ref<any>; | ||
callStatus: import("@vue/reactivity").Ref<any>; | ||
roomId: import("@vue/reactivity").Ref<any, any>; | ||
roomIdType: import("@vue/reactivity").Ref<any, any>; | ||
groupId: import("@vue/reactivity").Ref<any, any>; | ||
callMediaType: import("@vue/reactivity").Ref<any, any>; | ||
groupCallMembers: import("@vue/reactivity").Ref<any, any>; | ||
callStatus: import("@vue/reactivity").Ref<any, any>; | ||
}; |
export declare function useNetWorkStatus(): { | ||
netWorkQualityList: import("@vue/reactivity").Ref<any>; | ||
netWorkQualityList: import("@vue/reactivity").Ref<any, any>; | ||
}; |
@@ -1,1 +0,1 @@ | ||
export declare function usePlayer(): import("@vue/reactivity").Ref<any>; | ||
export declare function usePlayer(): import("@vue/reactivity").Ref<any, any>; |
import { Ref } from '../../adapter-vue'; | ||
export declare function usePopover(): Ref<string>; | ||
export declare function usePopover(): Ref<string, string>; |
export declare function useTip(): { | ||
tip: import("@vue/reactivity").Ref<string>; | ||
show: import("@vue/reactivity").Ref<boolean>; | ||
duration: import("@vue/reactivity").Ref<number>; | ||
tip: import("@vue/reactivity").Ref<string, string>; | ||
show: import("@vue/reactivity").Ref<boolean, boolean>; | ||
duration: import("@vue/reactivity").Ref<number, number>; | ||
}; |
@@ -1,1 +0,1 @@ | ||
export declare function useViewBackgroundConfig(): import("@vue/reactivity").Ref<import("../../TUICallService/const").IViewBackgroundImage>; | ||
export declare function useViewBackgroundConfig(): import("@vue/reactivity").Ref<import("../../TUICallService/const").IViewBackgroundImage, import("../../TUICallService/const").IViewBackgroundImage>; |
@@ -15,2 +15,7 @@ import { IBellParams } from '../interface/index'; | ||
destroy(): void; | ||
private _handleAudioInterruptionBegin; | ||
private _handleAudioInterruptionEnd; | ||
private _handleBellContextError; | ||
private _addListenBellContextEvent; | ||
private _removeListenBellContextEvent; | ||
} |
import { ITUICallService, ICallParams, IGroupCallParams, ICallbackParam, ISelfInfoParams, IInviteUserParams, IJoinInGroupCallParams, IInitParams } from '../interface/ICallService'; | ||
import { LanguageType, LOG_LEVEL, VideoDisplayMode, VideoResolution, FeatureButton, LayoutMode } from '../const/index'; | ||
import { ITUIGlobal } from '../interface/ITUIGlobal'; | ||
import { ITUIStore } from '../interface/ITUIStore'; | ||
import { LOG_LEVEL, VideoDisplayMode, VideoResolution, FeatureButton, LayoutMode } from '../const/index'; | ||
import { ITUIGlobal, ITUIStore } from '../interface/index'; | ||
declare const TUIGlobal: ITUIGlobal; | ||
@@ -20,2 +19,4 @@ declare const TUIStore: ITUIStore; | ||
private _defaultOfflinePushInfo; | ||
private _chatCombine; | ||
private _engineEventHandler; | ||
constructor(); | ||
@@ -31,3 +32,3 @@ static getInstance(): TUICallService; | ||
setLogLevel(level: LOG_LEVEL): void; | ||
setLanguage(language: LanguageType): void; | ||
setLanguage(language: string): void; | ||
enableFloatWindow(enable: boolean): void; | ||
@@ -55,31 +56,7 @@ setSelfInfo(params: ISelfInfoParams): Promise<void>; | ||
setSoundMode(type?: string): void; | ||
getTim(): any; | ||
setBlurBackground(enable: boolean): Promise<void>; | ||
switchDevice(params: any): Promise<void>; | ||
getDeviceList(deviceType: string): Promise<any>; | ||
private _addListenTuiCallEngineEvent; | ||
private _removeListenTuiCallEngineEvent; | ||
private _handleError; | ||
private _handleNewInvitationReceived; | ||
private _handleUserAccept; | ||
private _handleUserEnter; | ||
private _callerChangeToConnected; | ||
private _handleUserLeave; | ||
private _unNormalEventsManager; | ||
private _handleInviteeReject; | ||
private _handleNoResponse; | ||
private _handleLineBusy; | ||
private _handleCallingCancel; | ||
private _handleCallingEnd; | ||
private _handleSDKReady; | ||
private _handleKickedOut; | ||
private _handleCallTypeChange; | ||
private _messageSentByMe; | ||
private _handleNetworkQuality; | ||
private _handleUserVideoAvailable; | ||
private _handleUserAudioAvailable; | ||
private _handleUserVoiceVolume; | ||
private _handleDeviceUpdate; | ||
private _updateDeviceList; | ||
private _handleUserUpdate; | ||
private _handleCallError; | ||
beforeCalling: ((...args: any[]) => void) | undefined; | ||
@@ -92,6 +69,5 @@ afterCalling: ((...args: any[]) => void) | undefined; | ||
setCallback(params: ICallbackParam): void; | ||
getDeviceList(deviceType: string): Promise<any>; | ||
toggleMinimize(): void; | ||
private _executeExternalBeforeCalling; | ||
private _executeExternalAfterCalling; | ||
executeExternalBeforeCalling(): void; | ||
executeExternalAfterCalling(): void; | ||
handleExceptionExit(): Promise<void>; | ||
@@ -101,20 +77,12 @@ handlePusherError(event: any): void; | ||
setVideoResolution(resolution: VideoResolution): Promise<void>; | ||
private _startRemoteView; | ||
private _setRemoteUserInfoAudioVideoAvailable; | ||
private _setLocalUserInfoAudioVideoAvailable; | ||
startTimer(): void; | ||
private _handleCallError; | ||
private _updateCallStoreBeforeCall; | ||
private _updateCallStoreAfterCall; | ||
private _resetCallStore; | ||
private _noDevicePermissionToast; | ||
private _startTimer; | ||
private _getFeatureButtonDefaultState; | ||
private _updateCallDuration; | ||
private _stopTimer; | ||
private _deleteRemoteUser; | ||
private _analyzeEventData; | ||
private _addListenChatEvent; | ||
private _removeListenChatEvent; | ||
private _handleGroupAttributesUpdated; | ||
private _resetCallStore; | ||
getGroupMemberList(count: number, offset: number): Promise<any>; | ||
getGroupProfile(): Promise<any>; | ||
getFeatureButtonDefaultState(buttonName: FeatureButton): any; | ||
private _handleCallStatusChange; | ||
@@ -124,7 +92,14 @@ private _watchTUIStore; | ||
bindTUICore(TUICore: any): void; | ||
private _callTUIService; | ||
onNotifyEvent(eventName: string, subKey: string, options?: any): Promise<void>; | ||
onCall(method: String, params: any): Promise<void>; | ||
private _handleTUICoreOnClick; | ||
onGetExtension(extensionID: string, params: any): any[]; | ||
onGetExtension(extensionID: string, params: any): any; | ||
getTim(): any; | ||
setIsFromChat(isFromChat: boolean): void; | ||
setCurrentGroupId(groupId: string): void; | ||
getCurrentGroupId(): string; | ||
setDefaultOfflinePushInfo(offlinePushInfo: any): void; | ||
getDefaultOfflinePushInfo(): { | ||
title: string; | ||
description: string; | ||
}; | ||
} |
@@ -0,18 +1,42 @@ | ||
import { CallMediaType } from '../const/index'; | ||
import { IUserInfo } from '../interface/ICallService'; | ||
import { ITUIStore } from '../interface/ITUIStore'; | ||
export declare function setDefaultUserInfo(userId: string, domId?: string): IUserInfo; | ||
export declare function getMyProfile(myselfUserId: string, tim: any, TUIStore: any): Promise<IUserInfo>; | ||
export declare function getRemoteUserProfile(userIdList: Array<string>, tim: any, TUIStore: any): Promise<any>; | ||
export declare function generateText(TUIStore: ITUIStore, key: string, prefix?: string, suffix?: string): string; | ||
export declare function generateStatusChangeText(TUIStore: ITUIStore): string; | ||
export declare function getMyProfile(myselfUserId: string, tim: any): Promise<IUserInfo>; | ||
export declare function getRemoteUserProfile(userIdList: Array<string>, tim: any): Promise<any>; | ||
export declare function generateText(key: string, prefix?: string, suffix?: string): string; | ||
export declare function generateStatusChangeText(): string; | ||
export declare function getGroupMemberList(groupID: string, tim: any, count: any, offset: any): Promise<any>; | ||
export declare function getGroupProfile(groupID: string, tim: any): Promise<any>; | ||
export declare function getGroupAttributes(tim: any, groupId: string): Promise<any>; | ||
export declare function updateStoreBasedOnGroupAttributes(groupAttributes: any, TUIStore: ITUIStore, that: any): Promise<void>; | ||
/** | ||
* update roomId and roomIdType | ||
* @param {ITUIStore} TUIStore TUIStore instance | ||
* @param {number} roomId number roomId | ||
* @param {string} strRoomId string roomId | ||
*/ | ||
export declare function updateRoomIdAndRoomIdType(TUIStore: ITUIStore, roomId: any, strRoomId: any): void; | ||
export declare function updateRoomIdAndRoomIdType(roomId: any, strRoomId: any): void; | ||
/** | ||
* web and miniProgram call engine throw event data structure are different | ||
* @param {any} event call engine throw out data | ||
* @returns {any} data | ||
*/ | ||
export declare function analyzeEventData(event: any): any; | ||
/** | ||
* delete user from remoteUserInfoList | ||
* @param {string[]} userIdList to be deleted userIdList | ||
* @param {ITUIStore} TUIStore TUIStore instance | ||
*/ | ||
export declare function deleteRemoteUser(userIdList: string[]): void; | ||
export declare function updateDeviceList(tuiCallEngine: any): void; | ||
/** | ||
* update the no device permission toast | ||
* @param {any} error error | ||
* @param {CallMediaType} type call midia type | ||
* @param {any} tuiCallEngine TUICallEngine instance | ||
*/ | ||
export declare function noDevicePermissionToast(error: any, type: CallMediaType, tuiCallEngine: any): void; | ||
/** | ||
* set localUserInfo audio/video available | ||
* @param {boolean} isAvailable is available | ||
* @param {string} type callMediaType 'audio' | 'video' | ||
* @param {ITUIStore} TUIStore TUIStore instance | ||
*/ | ||
export declare function setLocalUserInfoAudioVideoAvailable(isAvailable: boolean, type: string): void; |
@@ -61,2 +61,3 @@ export declare const en: { | ||
"The other user network is poor during the current call": string; | ||
"TUICallKit initialization login is not complete. You need to use this API after the init API is finished.": string; | ||
'Those involved': string; | ||
@@ -63,0 +64,0 @@ call: string; |
@@ -55,2 +55,3 @@ export declare const ja_JP: { | ||
"The other user network is poor during the current call": string; | ||
"TUICallKit initialization login is not complete. You need to use this API after the init API is finished.": string; | ||
timeout: string; | ||
@@ -57,0 +58,0 @@ 'kick out': string; |
@@ -61,2 +61,3 @@ export declare const zh: { | ||
"The other user network is poor during the current call": string; | ||
"TUICallKit initialization login is not complete. You need to use this API after the init API is finished.": string; | ||
timeout: string; | ||
@@ -63,0 +64,0 @@ 'kick out': string; |
import { avoidRepeatedCall } from './avoidRepeatedCall'; | ||
import { paramValidate } from './validateParams'; | ||
import { VALIDATE_PARAMS } from './validateConfig'; | ||
export { VALIDATE_PARAMS, paramValidate, avoidRepeatedCall, }; | ||
import { statusValidate } from './validateStatus'; | ||
export { VALIDATE_PARAMS, paramValidate, avoidRepeatedCall, statusValidate, }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1838594
454
30893
2
+ Addedtuicall-engine-wx@2.2.4-beta.1(transitive)
- Removedtuicall-engine-wx@2.2.8(transitive)