|
@@ -150,8 +150,13 @@ function handleInfoAdd(tip: string) {
|
|
|
} as type_dyaw_xlfw_zxhd_log
|
|
|
emits('update-info', fullSendData)
|
|
|
dxzl_id = `${res.data.insert_id}`
|
|
|
+ console.info('[success][in handleInfoAdd] end ', fullSendData);
|
|
|
return fullSendData
|
|
|
}
|
|
|
+ console.error('[fail][in handleInfoAdd] end ', res)
|
|
|
+ return Promise.reject()
|
|
|
+ }).catch(err => {
|
|
|
+ console.error('[error][in handleInfoAdd] end ', err)
|
|
|
return Promise.reject()
|
|
|
})
|
|
|
}
|
|
@@ -173,11 +178,16 @@ function handleInfoEdit(data: Partial<type_dyaw_xlfw_zxhd_log>, tip?: string) {
|
|
|
dxzl_id: dxzl_id!,
|
|
|
..._reqDate
|
|
|
}, true)
|
|
|
+ console.info('[success][in handleInfoEdit] end ', _reqDate);
|
|
|
return {
|
|
|
dxzl_id: dxzl_id!,
|
|
|
..._reqDate
|
|
|
}
|
|
|
}
|
|
|
+ console.error('[fail][in handleInfoEdit] end ', res)
|
|
|
+ return Promise.reject()
|
|
|
+ }).catch(err => {
|
|
|
+ console.error('[error][in handleInfoEdit] end ', err)
|
|
|
return Promise.reject()
|
|
|
})
|
|
|
}
|
|
@@ -254,6 +264,7 @@ async function getRtcOption() {
|
|
|
}).then(async res => {
|
|
|
if (res.code === '1') {
|
|
|
let resp: { jgim_roomid: string; rtc_appid: string; rtc_token: string } = res.data.one_info
|
|
|
+ console.info('[success][in getRtcOption] end ', resp)
|
|
|
return rtcOptions = {
|
|
|
appId: resp.rtc_appid,
|
|
|
// channel: resp.jgim_roomid,
|
|
@@ -261,15 +272,14 @@ async function getRtcOption() {
|
|
|
token: resp.rtc_token,
|
|
|
// uid: user.user_id
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
+ console.error('[fail][in getRtcOption] end ', res)
|
|
|
showFailToast('服务器繁忙,请稍后再试')
|
|
|
- console.error(res);
|
|
|
}
|
|
|
})
|
|
|
- console.info('rtcOptions', rtcOptions);
|
|
|
} catch (error) {
|
|
|
+ console.error('[error][in getRtcOption] end ', error)
|
|
|
showFailToast('服务器繁忙,请稍后再试')
|
|
|
- console.error(error);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -322,18 +332,22 @@ async function handleAudioChatStart() {
|
|
|
|
|
|
console.info('发送拨号信息')
|
|
|
const fullSendData = await handleInfoAdd('拨号中')
|
|
|
-
|
|
|
+ console.info('发送拨号信息结束')
|
|
|
|
|
|
await nextTick(async () => {
|
|
|
+ console.info('初始化rtc频道')
|
|
|
await rtcInstance.client!.join(rtcOptions.appId, rtcOptions.channel, rtcOptions?.token, /*rtcOptions.uid*/ user.user_id);
|
|
|
+ console.info('初始化rtc频道结束,开始创建本地音视频轨道')
|
|
|
rtcInstance.localAudioTrack = await AgoraRTC.createMicrophoneAudioTrack();
|
|
|
// await rtcInstance.client!.publish(rtcInstance.localAudioTrack);
|
|
|
if (mode === 'video') {
|
|
|
+ console.info('创建本地视频轨道')
|
|
|
rtcInstance.localVideoTrack = await AgoraRTC.createCameraVideoTrack();
|
|
|
+ console.info('创建本地视频轨道结束,开始播放本地视频')
|
|
|
rtcInstance.localVideoTrack.play(LocalPlayerContainerRef as HTMLElement);
|
|
|
// await rtcInstance.client!.publish(rtcInstance.localVideoTrack);
|
|
|
}
|
|
|
-
|
|
|
+ console.info('socket发送拨号信息')
|
|
|
socketSend(ws2, {
|
|
|
dxzl_stu_user_id: dyaw_xlfw_zxhd!.dxz_stu_user_id,
|
|
|
dxzl_tea_user_id: dyaw_xlfw_zxhd!.dxz_tea_user_id,
|
|
@@ -353,70 +367,109 @@ async function handleAudioChatStart() {
|
|
|
|
|
|
}
|
|
|
async function handleAudioChatCancel() {
|
|
|
- const fullSendData = await handleInfoEdit({ dxzl_status: '2' }, '已取消')
|
|
|
- socketSend(ws2, {
|
|
|
- dxzl_stu_user_id: dyaw_xlfw_zxhd!.dxz_stu_user_id,
|
|
|
- dxzl_tea_user_id: dyaw_xlfw_zxhd!.dxz_tea_user_id,
|
|
|
- operate: CHAT_OPERATION.CANCEL,
|
|
|
- fullSendData
|
|
|
- })
|
|
|
- isOpen = false
|
|
|
- rtcInstance.client?.leave();
|
|
|
- handleSwitchUse(false)
|
|
|
+ console.info('handleAudioChatCancel start')
|
|
|
+ try {
|
|
|
+ const fullSendData = await handleInfoEdit({ dxzl_status: '2' }, '已取消')
|
|
|
+ socketSend(ws2, {
|
|
|
+ dxzl_stu_user_id: dyaw_xlfw_zxhd!.dxz_stu_user_id,
|
|
|
+ dxzl_tea_user_id: dyaw_xlfw_zxhd!.dxz_tea_user_id,
|
|
|
+ operate: CHAT_OPERATION.CANCEL,
|
|
|
+ fullSendData
|
|
|
+ })
|
|
|
+ isOpen = false
|
|
|
+ rtcInstance.client?.leave();
|
|
|
+ handleSwitchUse(false)
|
|
|
+ console.info('[success]handleAudioChatCancel end')
|
|
|
+ } catch (error) {
|
|
|
+ console.error('[error]handleAudioChatCancel end', error)
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
async function handleAudioChatAccept() {
|
|
|
+ console.info('handleAudioChatAccept start')
|
|
|
currentChatStatus = CHAT_STATUS.WAITING_ACCEPT
|
|
|
|
|
|
+ try {
|
|
|
+ console.info('发送接听信息')
|
|
|
+ const fullSendData = await handleInfoEdit({ dxzl_status: '3' }, '通话中')
|
|
|
+ console.info('发送接听信息结束')
|
|
|
+ // ...
|
|
|
+ console.info('初始化rtc频道')
|
|
|
+ initRtcClient()
|
|
|
|
|
|
- const fullSendData = await handleInfoEdit({ dxzl_status: '3' }, '通话中')
|
|
|
- // ...
|
|
|
- await getRtcOption()
|
|
|
- initRtcClient()
|
|
|
- await rtcInstance.client!.join(rtcOptions.appId, rtcOptions.channel, rtcOptions?.token, /*rtcOptions.uid*/ user.user_id);
|
|
|
- rtcInstance.localAudioTrack = await AgoraRTC.createMicrophoneAudioTrack();
|
|
|
- await rtcInstance.client!.publish(rtcInstance.localAudioTrack);
|
|
|
- if (mode === 'video') {
|
|
|
- rtcInstance.localVideoTrack = await AgoraRTC.createCameraVideoTrack();
|
|
|
- rtcInstance.localVideoTrack.play(LocalPlayerContainerRef as HTMLElement);
|
|
|
- await rtcInstance.client!.publish(rtcInstance.localVideoTrack);
|
|
|
+ await getRtcOption()
|
|
|
+ console.info('初始化rtc频道')
|
|
|
+ await rtcInstance.client!.join(rtcOptions.appId, rtcOptions.channel, rtcOptions?.token, /*rtcOptions.uid*/ user.user_id);
|
|
|
+ console.info('初始化rtc频道结束,开始创建本地音视频轨道')
|
|
|
+ rtcInstance.localAudioTrack = await AgoraRTC.createMicrophoneAudioTrack();
|
|
|
+ console.info('创建本地音频轨道结束,发布本地音频')
|
|
|
+ await rtcInstance.client!.publish(rtcInstance.localAudioTrack);
|
|
|
+ console.info('发布本地音频结束')
|
|
|
+ if (mode === 'video') {
|
|
|
+ console.info('创建本地视频轨道')
|
|
|
+ rtcInstance.localVideoTrack = await AgoraRTC.createCameraVideoTrack();
|
|
|
+ console.info('创建本地视频轨道结束,开始播放本地视频')
|
|
|
+ rtcInstance.localVideoTrack.play(LocalPlayerContainerRef as HTMLElement);
|
|
|
+ console.info('发布本地视频')
|
|
|
+ await rtcInstance.client!.publish(rtcInstance.localVideoTrack);
|
|
|
+ console.info('发布本地视频结束')
|
|
|
+ }
|
|
|
+ //
|
|
|
+ console.info('socket发送已接听信息')
|
|
|
+ socketSend(ws2, {
|
|
|
+ dxzl_stu_user_id: dyaw_xlfw_zxhd!.dxz_stu_user_id,
|
|
|
+ dxzl_tea_user_id: dyaw_xlfw_zxhd!.dxz_tea_user_id,
|
|
|
+ operate: CHAT_OPERATION.ACCEPT,
|
|
|
+ fullSendData
|
|
|
+ })
|
|
|
+ console.info('socket发送已接听信息结束')
|
|
|
+ currentChatStatus = CHAT_STATUS.CHATING
|
|
|
+ offsetTime = 0
|
|
|
+ offsetTimer = setInterval(() => {
|
|
|
+ offsetTime = (offsetTime as number + 1)
|
|
|
+ }, 1000)
|
|
|
+ } catch (error) {
|
|
|
+ console.error('[error] handleAudioChatAccept', error)
|
|
|
}
|
|
|
- //
|
|
|
- socketSend(ws2, {
|
|
|
- dxzl_stu_user_id: dyaw_xlfw_zxhd!.dxz_stu_user_id,
|
|
|
- dxzl_tea_user_id: dyaw_xlfw_zxhd!.dxz_tea_user_id,
|
|
|
- operate: CHAT_OPERATION.ACCEPT,
|
|
|
- fullSendData
|
|
|
- })
|
|
|
- currentChatStatus = CHAT_STATUS.CHATING
|
|
|
- offsetTime = 0
|
|
|
- offsetTimer = setInterval(() => {
|
|
|
- offsetTime = (offsetTime as number + 1)
|
|
|
- }, 1000)
|
|
|
+
|
|
|
}
|
|
|
async function handleAudioChatDeny() {
|
|
|
- const fullSendData = await handleInfoEdit({ dxzl_status: '4' }, '已拒接')
|
|
|
- socketSend(ws2, {
|
|
|
- dxzl_stu_user_id: dyaw_xlfw_zxhd!.dxz_stu_user_id,
|
|
|
- dxzl_tea_user_id: dyaw_xlfw_zxhd!.dxz_tea_user_id,
|
|
|
- operate: CHAT_OPERATION.DENY,
|
|
|
- fullSendData
|
|
|
- })
|
|
|
- isOpen = false
|
|
|
+ console.info('handleAudioChatDeny start')
|
|
|
+ try {
|
|
|
+ const fullSendData = await handleInfoEdit({ dxzl_status: '4' }, '已拒接')
|
|
|
+ socketSend(ws2, {
|
|
|
+ dxzl_stu_user_id: dyaw_xlfw_zxhd!.dxz_stu_user_id,
|
|
|
+ dxzl_tea_user_id: dyaw_xlfw_zxhd!.dxz_tea_user_id,
|
|
|
+ operate: CHAT_OPERATION.DENY,
|
|
|
+ fullSendData
|
|
|
+ })
|
|
|
+ isOpen = false
|
|
|
+ console.info('[success]handleAudioChatDeny end')
|
|
|
+ } catch (error) {
|
|
|
+ console.error('[error] handleAudioChatDeny', error)
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
async function handleAudioChatEnd() {
|
|
|
- const fullSendData = await handleInfoEdit({ dxzl_status: '4' }, /*'已结束'*/formatOffsetSec(offsetTime))
|
|
|
- offsetTimer && clearInterval(offsetTimer)
|
|
|
- await rtcInstance.client!.leave();
|
|
|
- handleSwitchUse(false)
|
|
|
-
|
|
|
- socketSend(ws2, {
|
|
|
- dxzl_stu_user_id: dyaw_xlfw_zxhd!.dxz_stu_user_id,
|
|
|
- dxzl_tea_user_id: dyaw_xlfw_zxhd!.dxz_tea_user_id,
|
|
|
- operate: CHAT_OPERATION.END,
|
|
|
- fullSendData
|
|
|
- })
|
|
|
- isOpen = false
|
|
|
+ console.info('handleAudioChatEnd start')
|
|
|
+ try {
|
|
|
+ const fullSendData = await handleInfoEdit({ dxzl_status: '4' }, /*'已结束'*/formatOffsetSec(offsetTime))
|
|
|
+ offsetTimer && clearInterval(offsetTimer)
|
|
|
+ await rtcInstance.client!.leave();
|
|
|
+ handleSwitchUse(false)
|
|
|
+
|
|
|
+ socketSend(ws2, {
|
|
|
+ dxzl_stu_user_id: dyaw_xlfw_zxhd!.dxz_stu_user_id,
|
|
|
+ dxzl_tea_user_id: dyaw_xlfw_zxhd!.dxz_tea_user_id,
|
|
|
+ operate: CHAT_OPERATION.END,
|
|
|
+ fullSendData
|
|
|
+ })
|
|
|
+ isOpen = false
|
|
|
+ console.info('[success]handleAudioChatEnd end')
|
|
|
+ } catch (error) {
|
|
|
+ console.error('[error] handleAudioChatEnd', error)
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
let audioInUse = $ref(true)
|