UNPKG

fcc-core

Version:

Fusion communication center.

141 lines (140 loc) 4.21 kB
// 语音挂断事件 const OnDialVoiceDropped = (xwEvent, type, result) => { xwEvent.emit('OnDialVoiceDropped', { callId: xwEvent.xw.SEND_ICP_CODE || '', type: type, msg: result.resultMsg || '' }) setTimeout(() => { xwEvent.xw.SEND_ICP_CODE = '' }) } // 语音来电 const OnDialVoiceRequest = (xwEvent, result) => { xwEvent.emit('OnDialVoiceRequest', { callId: xwEvent.xw.SEND_ICP_CODE || '', caller: xwEvent.xw.userInfo.USER_ACCOUNT }) } // 语音接听 1己方接听 2对方接听 const OnDialVoiceAnswer = (xwEvent, type) => { xwEvent.emit('OnDialVideoAnswer', { caller: xwEvent.xw.userInfo.USER_ACCOUNT, type }) } // 视频挂断 const OnDialVideoDropped = (xwEvent, type, result) => { xwEvent.emit('OnDialVideoDropped', { callId: xwEvent.xw.SEND_ICP_CODE || '', type: type, msg: result.resultMsg || '' }) setTimeout(() => { xwEvent.xw.SEND_ICP_CODE = '' }) } // 视频来电 const OnDialVideoRequest = (xwEvent, result) => { xwEvent.emit('OnOppositeCallAnswer', { callId: xwEvent.xw.SEND_ICP_CODE || '', caller: xwEvent.xw.userInfo.USER_ACCOUNT }) } // 视频接通 const OnDialVideoAnswer = (xwEvent, type) => { xwEvent.emit('OnDialVideoAnswer', { caller: xwEvent.xw.userInfo.USER_ACCOUNT, type }) } export default xwEvent => { // 监听挂断事件 xwEvent.xw.exe.on('OnCallEnd', result => { if (result.resultCode === 0) { // 音频挂断 if (result.data && (!result.data.isVideo || result.data.isVideo === '0')) { OnDialVoiceDropped(xwEvent, '1', result) } else { OnDialVideoDropped(xwEvent, '1', result) } } else { if (!result.data.isVideo || result.data.isVideo === '0') { OnDialVoiceDropped(xwEvent, '2', result) } else { OnDialVideoDropped(xwEvent, '2', result) } } }) // 监听主动挂断 xwEvent.xw.exe.on('OnOppositeCallEnd', result => { if (result.resultCode === 0) { // 音频挂断 if (!result.data.isVideo || result.data.isVideo === '0') { OnDialVoiceDropped(xwEvent, '1', result) } else { OnDialVideoDropped(xwEvent, '1', result) } } else { if (!result.data.isVideo || result.data.isVideo === '0') { OnDialVoiceDropped(xwEvent, '2', result) } else { OnDialVideoDropped(xwEvent, '2', result) } } }) // 监听主呼接听事件 xwEvent.xw.exe.on('OnOppositeCall', result => { if (result.resultCode === 0) { // 接听 xwEvent.xw.SEND_ICP_CODE = result.data.callId || '' if (!result.data.isVideo || result.data.isVideo === '0') { OnDialVoiceRequest(xwEvent, result) } else { OnDialVideoRequest(xwEvent, result) } } else { if (!result.data.isVideo || result.data.isVideo === '0') { OnDialVoiceRequest(xwEvent, result) } else { OnDialVideoRequest(xwEvent, result) } } }) // 监听被呼接听事件 xwEvent.xw.exe.on('OnCallAnswer', result => { if (result.resultCode === 0) { // 接听 xwEvent.xw.SEND_ICP_CODE = result.data.callId || '' if (!result.data.isVideo || result.data.isVideo === '0') { OnDialVoiceAnswer(xwEvent, '1') } else { OnDialVideoAnswer(xwEvent, '1') } } else { if (!result.data.isVideo || result.data.isVideo === '0') { OnDialVoiceAnswer(xwEvent, '1') } else { OnDialVideoAnswer(xwEvent, 1) } } }) // 监听主呼接听事件 xwEvent.xw.exe.on('OnOppositeCallAnswer', result => { if (result.resultCode === 0) { // 接听 xwEvent.xw.SEND_ICP_CODE = result.data.callId || '' if (!result.data.isVideo || result.data.isVideo === '0') { OnDialVoiceAnswer(xwEvent, '2') } else { OnDialVideoAnswer(xwEvent, '2') } } else { if (!result.data.isVideo || result.data.isVideo === '0') { OnDialVoiceAnswer(xwEvent, '2') } else { OnDialVideoAnswer(xwEvent, '2') } } }) }