视频消息推送,完善用户退出视频逻辑
This commit is contained in:
parent
aea17133e4
commit
dd6156c274
37
src/App.vue
37
src/App.vue
@ -1,13 +1,18 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
<router-view></router-view>
|
<router-view></router-view>
|
||||||
|
|
||||||
|
<VoiceCallDialog v-if="acceptDialog" :acceptDialog.sync="acceptDialog" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {mapState} from 'vuex'
|
import {mapState} from 'vuex'
|
||||||
import fetchApi from "@/services/fetchApi";
|
import voiceCall from "@/services/voiceCall";
|
||||||
export default {
|
export default {
|
||||||
|
components: {
|
||||||
|
VoiceCallDialog: () => import('./components/VoiceCallDialog'),
|
||||||
|
},
|
||||||
name: "App",
|
name: "App",
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
@ -16,7 +21,7 @@ export default {
|
|||||||
},
|
},
|
||||||
data(){
|
data(){
|
||||||
return {
|
return {
|
||||||
|
acceptDialog: null,// id
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -51,9 +56,33 @@ export default {
|
|||||||
window.tccc.on('tokenExpired', ({message}) => {
|
window.tccc.on('tokenExpired', ({message}) => {
|
||||||
console.error('---初始化失败', 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) => {
|
window.tccc.on('callIn', (callback) => {
|
||||||
// acceptID = callback.id;
|
this.acceptDialog = callback;
|
||||||
|
// this.acceptID = callback.id;
|
||||||
console.log(callback, '---呼入')
|
console.log(callback, '---呼入')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -61,7 +90,7 @@ export default {
|
|||||||
initVoiceCall(){
|
initVoiceCall(){
|
||||||
// 是否已经创建
|
// 是否已经创建
|
||||||
if (this.scriptWithDataSetExists('telephone')){return}
|
if (this.scriptWithDataSetExists('telephone')){return}
|
||||||
fetchApi.webCalling().then(res => {
|
voiceCall.webCalling().then(res => {
|
||||||
const {agent, token, sdkAppId, agentId, sdkURL} = res;
|
const {agent, token, sdkAppId, agentId, sdkURL} = res;
|
||||||
// console.log(res, '---res')
|
// console.log(res, '---res')
|
||||||
if (agent){
|
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.stopLocalAudio();// 停止本地麦克风的采集及发布
|
||||||
await this.trtc.stopLocalVideo();// 停止本地摄像头的采集、预览及发布
|
await this.trtc.stopLocalVideo();// 停止本地摄像头的采集、预览及发布
|
||||||
|
this.trtc = null;
|
||||||
// await this.trtc.stopScreenShare();// 停止屏幕分享
|
// await this.trtc.stopScreenShare();// 停止屏幕分享
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -389,18 +390,25 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
let jsonString = JSON.stringify({behavior: 'offAudio', userId: userId});
|
let json = {behavior: 'offAudio', userId: userId}
|
||||||
let encoder = new TextEncoder();
|
let data = {
|
||||||
let encoded = encoder.encode(jsonString).buffer;
|
destination: `/topic/video-room/${this.eventDialog.roomId}`,
|
||||||
console.log(encoded, '---关闭远端声音')
|
body: JSON.stringify(json)
|
||||||
let decoder = new TextDecoder();
|
}
|
||||||
let decodedString = decoder.decode(encoded);
|
this.$stompSocket.publish(data)
|
||||||
let parsedObj = JSON.parse(decodedString);
|
|
||||||
console.log(parsedObj, '---解析关闭远端声音');
|
// let jsonString = JSON.stringify({behavior: 'offAudio', userId: userId});
|
||||||
await this.trtc.sendCustomMessage({
|
// let encoder = new TextEncoder();
|
||||||
cmdId: 1,
|
// let encoded = encoder.encode(jsonString).buffer;
|
||||||
data: encoded
|
// 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) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
@ -419,13 +427,20 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
let jsonString = JSON.stringify({behavior: 'onAudio', userId: userId});
|
|
||||||
let encoder = new TextEncoder();
|
let json = {behavior: 'onAudio', userId: userId}
|
||||||
let encoded = encoder.encode(jsonString).buffer;
|
let data = {
|
||||||
await this.trtc.sendCustomMessage({
|
destination: `/topic/video-room/${this.eventDialog.roomId}`,
|
||||||
cmdId: 2,
|
body: JSON.stringify(json)
|
||||||
data: encoded
|
}
|
||||||
});
|
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) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
@ -434,13 +449,19 @@ export default {
|
|||||||
async handleKickOut(userId) {
|
async handleKickOut(userId) {
|
||||||
console.log(userId, '---踢出远端用户')
|
console.log(userId, '---踢出远端用户')
|
||||||
try {
|
try {
|
||||||
let jsonString = JSON.stringify({behavior: 'kickOut', userId: userId});
|
let json = {behavior: 'kickOut', userId: userId}
|
||||||
let encoder = new TextEncoder();
|
let data = {
|
||||||
let encoded = encoder.encode(jsonString).buffer;
|
destination: `/topic/video-room/${this.eventDialog.roomId}`,
|
||||||
await this.trtc.sendCustomMessage({
|
body: JSON.stringify(json)
|
||||||
cmdId: 3,
|
}
|
||||||
data: encoded
|
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) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
@ -502,6 +523,9 @@ export default {
|
|||||||
if (this.timerId) {
|
if (this.timerId) {
|
||||||
clearInterval(this.timerId);
|
clearInterval(this.timerId);
|
||||||
}
|
}
|
||||||
|
if (this.trtc){
|
||||||
|
this.handleKickedOut();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -47,9 +47,5 @@ const fetchApi = {
|
|||||||
viewFullFile: data => {
|
viewFullFile: data => {
|
||||||
return service.service.post(`${apiAdmin}upload/full`, data,{hideLoading:true})
|
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;
|
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