视频消息推送,完善用户退出视频逻辑
This commit is contained in:
parent
aea17133e4
commit
dd6156c274
37
src/App.vue
37
src/App.vue
@ -1,13 +1,18 @@
|
||||
<template>
|
||||
<div id="app">
|
||||
<router-view></router-view>
|
||||
|
||||
<VoiceCallDialog v-if="acceptDialog" :acceptDialog.sync="acceptDialog" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {mapState} from 'vuex'
|
||||
import fetchApi from "@/services/fetchApi";
|
||||
import voiceCall from "@/services/voiceCall";
|
||||
export default {
|
||||
components: {
|
||||
VoiceCallDialog: () => import('./components/VoiceCallDialog'),
|
||||
},
|
||||
name: "App",
|
||||
computed: {
|
||||
...mapState({
|
||||
@ -16,7 +21,7 @@ export default {
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
|
||||
acceptDialog: null,// id
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
@ -51,9 +56,33 @@ export default {
|
||||
window.tccc.on('tokenExpired', ({message}) => {
|
||||
console.error('---初始化失败', message)
|
||||
})
|
||||
|
||||
this.acceptDialog = {
|
||||
"sessionId": "32cca051-dcae-4269-ae12-e8eca5e02146",
|
||||
"calleePhoneNumber": "008605305343323",
|
||||
"callerPhoneNumber": "008613882832314",
|
||||
"protectedCallee": "008605305343323",
|
||||
"protectedCaller": "008613882832314",
|
||||
"ivrPath": [
|
||||
{
|
||||
"key": "1",
|
||||
"label": "分支内容1"
|
||||
}
|
||||
],
|
||||
"callerLocation": "四川达州移动",
|
||||
"timeout": 30,
|
||||
"type": "phone",
|
||||
"serverType": "staffSeat",
|
||||
"aiEnabled": false,
|
||||
"id": "32cca051-dcae-4269-ae12-e8eca5e02146",
|
||||
"phone": "008613882832314",
|
||||
"direction": "0",
|
||||
"startCallTime": 1736923493486
|
||||
};
|
||||
// 呼入事件
|
||||
window.tccc.on('callIn', (callback) => {
|
||||
// acceptID = callback.id;
|
||||
this.acceptDialog = callback;
|
||||
// this.acceptID = callback.id;
|
||||
console.log(callback, '---呼入')
|
||||
})
|
||||
})
|
||||
@ -61,7 +90,7 @@ export default {
|
||||
initVoiceCall(){
|
||||
// 是否已经创建
|
||||
if (this.scriptWithDataSetExists('telephone')){return}
|
||||
fetchApi.webCalling().then(res => {
|
||||
voiceCall.webCalling().then(res => {
|
||||
const {agent, token, sdkAppId, agentId, sdkURL} = res;
|
||||
// console.log(res, '---res')
|
||||
if (agent){
|
||||
|
||||
31
src/components/VoiceCallDialog.vue
Normal file
31
src/components/VoiceCallDialog.vue
Normal file
@ -0,0 +1,31 @@
|
||||
<template>
|
||||
<div></div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import voiceCall from "@/services/voiceCall";
|
||||
export default {
|
||||
name: "VoiceCallDialog",
|
||||
props: {
|
||||
acceptDialog: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {}
|
||||
},
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
},
|
||||
methods: {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
</style>
|
||||
@ -301,6 +301,7 @@ export default {
|
||||
}
|
||||
await this.trtc.stopLocalAudio();// 停止本地麦克风的采集及发布
|
||||
await this.trtc.stopLocalVideo();// 停止本地摄像头的采集、预览及发布
|
||||
this.trtc = null;
|
||||
// await this.trtc.stopScreenShare();// 停止屏幕分享
|
||||
},
|
||||
|
||||
@ -389,18 +390,25 @@ export default {
|
||||
}
|
||||
})
|
||||
}
|
||||
let jsonString = JSON.stringify({behavior: 'offAudio', userId: userId});
|
||||
let encoder = new TextEncoder();
|
||||
let encoded = encoder.encode(jsonString).buffer;
|
||||
console.log(encoded, '---关闭远端声音')
|
||||
let decoder = new TextDecoder();
|
||||
let decodedString = decoder.decode(encoded);
|
||||
let parsedObj = JSON.parse(decodedString);
|
||||
console.log(parsedObj, '---解析关闭远端声音');
|
||||
await this.trtc.sendCustomMessage({
|
||||
cmdId: 1,
|
||||
data: encoded
|
||||
});
|
||||
let json = {behavior: 'offAudio', userId: userId}
|
||||
let data = {
|
||||
destination: `/topic/video-room/${this.eventDialog.roomId}`,
|
||||
body: JSON.stringify(json)
|
||||
}
|
||||
this.$stompSocket.publish(data)
|
||||
|
||||
// let jsonString = JSON.stringify({behavior: 'offAudio', userId: userId});
|
||||
// let encoder = new TextEncoder();
|
||||
// let encoded = encoder.encode(jsonString).buffer;
|
||||
// console.log(encoded, '---关闭远端声音')
|
||||
// let decoder = new TextDecoder();
|
||||
// let decodedString = decoder.decode(encoded);
|
||||
// let parsedObj = JSON.parse(decodedString);
|
||||
// console.log(parsedObj, '---解析关闭远端声音');
|
||||
// await this.trtc.sendCustomMessage({
|
||||
// cmdId: 1,
|
||||
// data: encoded
|
||||
// });
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
@ -419,13 +427,20 @@ export default {
|
||||
}
|
||||
})
|
||||
}
|
||||
let jsonString = JSON.stringify({behavior: 'onAudio', userId: userId});
|
||||
let encoder = new TextEncoder();
|
||||
let encoded = encoder.encode(jsonString).buffer;
|
||||
await this.trtc.sendCustomMessage({
|
||||
cmdId: 2,
|
||||
data: encoded
|
||||
});
|
||||
|
||||
let json = {behavior: 'onAudio', userId: userId}
|
||||
let data = {
|
||||
destination: `/topic/video-room/${this.eventDialog.roomId}`,
|
||||
body: JSON.stringify(json)
|
||||
}
|
||||
this.$stompSocket.publish(data)
|
||||
// let jsonString = JSON.stringify({behavior: 'onAudio', userId: userId});
|
||||
// let encoder = new TextEncoder();
|
||||
// let encoded = encoder.encode(jsonString).buffer;
|
||||
// await this.trtc.sendCustomMessage({
|
||||
// cmdId: 2,
|
||||
// data: encoded
|
||||
// });
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
@ -434,13 +449,19 @@ export default {
|
||||
async handleKickOut(userId) {
|
||||
console.log(userId, '---踢出远端用户')
|
||||
try {
|
||||
let jsonString = JSON.stringify({behavior: 'kickOut', userId: userId});
|
||||
let encoder = new TextEncoder();
|
||||
let encoded = encoder.encode(jsonString).buffer;
|
||||
await this.trtc.sendCustomMessage({
|
||||
cmdId: 3,
|
||||
data: encoded
|
||||
});
|
||||
let json = {behavior: 'kickOut', userId: userId}
|
||||
let data = {
|
||||
destination: `/topic/video-room/${this.eventDialog.roomId}`,
|
||||
body: JSON.stringify(json)
|
||||
}
|
||||
this.$stompSocket.publish(data)
|
||||
// let jsonString = JSON.stringify({behavior: 'kickOut', userId: userId});
|
||||
// let encoder = new TextEncoder();
|
||||
// let encoded = encoder.encode(jsonString).buffer;
|
||||
// await this.trtc.sendCustomMessage({
|
||||
// cmdId: 3,
|
||||
// data: encoded
|
||||
// });
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
@ -502,6 +523,9 @@ export default {
|
||||
if (this.timerId) {
|
||||
clearInterval(this.timerId);
|
||||
}
|
||||
if (this.trtc){
|
||||
this.handleKickedOut();
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
@ -47,9 +47,5 @@ const fetchApi = {
|
||||
viewFullFile: data => {
|
||||
return service.service.post(`${apiAdmin}upload/full`, data,{hideLoading:true})
|
||||
},
|
||||
// ========================start:: 语音通话SDK======================================
|
||||
webCalling: data => {
|
||||
return service.service.get(`${apiAdmin}/api/trace/calling/init-web`, data)
|
||||
},
|
||||
}
|
||||
export default fetchApi;
|
||||
|
||||
17
src/services/voiceCall.js
Normal file
17
src/services/voiceCall.js
Normal file
@ -0,0 +1,17 @@
|
||||
import service from "./index";
|
||||
const apiAdmin = '/mediate/api/trace/calling/'
|
||||
const api = {
|
||||
// 初始化SDK
|
||||
webCalling: data => {
|
||||
return service.service.get(`${apiAdmin}init-web`, data)
|
||||
},
|
||||
// 匹配案件列表
|
||||
caseMatchList: data => {
|
||||
return service.service.post(`${apiAdmin}caseMatchList`, data)
|
||||
},
|
||||
// 关联案件
|
||||
caseMatch: data => {
|
||||
return service.service.post(`${apiAdmin}caseMatch`, data)
|
||||
},
|
||||
}
|
||||
export default api;
|
||||
Loading…
x
Reference in New Issue
Block a user