开发视频通话,修改两个bug
This commit is contained in:
@@ -36,7 +36,8 @@ export default function useWebSocket(aaas = null, options = {}) {
|
||||
onStartRecord,
|
||||
playPcmCallback,
|
||||
setPlayNumber = () => {}, //设置当前播放的音频的id,用于播放完成回调
|
||||
onError = () => {}
|
||||
onError = () => {},
|
||||
onClose = () => {},
|
||||
}) => {
|
||||
const wsUrl = _baseUrl + url + '?summary=' + getToken()
|
||||
const finalAuthParams = {
|
||||
@@ -53,10 +54,20 @@ export default function useWebSocket(aaas = null, options = {}) {
|
||||
}
|
||||
});
|
||||
ws.value.onOpen((res) => {
|
||||
console.log('onOpen', finalAuthParams);
|
||||
ws.value.send({
|
||||
data: ProtocolCodec.pack(MessageType.IDENTITY, finalAuthParams)
|
||||
});
|
||||
});
|
||||
ws.value.onError((err) => onError(err))
|
||||
|
||||
|
||||
|
||||
ws.value.onClose((err) => {
|
||||
console.log('onClose', err);
|
||||
onClose(err)
|
||||
});
|
||||
|
||||
ws.value.onMessage((res) => {
|
||||
const {
|
||||
msgType,
|
||||
@@ -76,19 +87,27 @@ export default function useWebSocket(aaas = null, options = {}) {
|
||||
playPcmCallback(numArray)
|
||||
break;
|
||||
case MessageType.ERROR:
|
||||
|
||||
switch (body.errCode) {
|
||||
case 1:
|
||||
// ASR或TTS初始化出错
|
||||
console.log('后端返回的错误', body.errMsg);
|
||||
|
||||
case 4:
|
||||
console.log('通话接通失败', body.errMsg);
|
||||
// 通话接通失败,请稍后再试!
|
||||
ws.value.close({
|
||||
code: 4001,
|
||||
reason: body.errMsg
|
||||
})
|
||||
break;
|
||||
default:
|
||||
// 其他错误码的默认处理(如果需要)
|
||||
// ws.value.close({
|
||||
// code: 1001,
|
||||
// reason: body.errMsg
|
||||
// })
|
||||
break;
|
||||
}
|
||||
console.log('错误', body);
|
||||
// this.handleErrorMessage(body);
|
||||
break;
|
||||
case MessageType.CONTROL_CMD:
|
||||
// 控制消息
|
||||
@@ -96,11 +115,8 @@ export default function useWebSocket(aaas = null, options = {}) {
|
||||
if (body.type === 1) { // 开始播放,记录当前播放的语音id
|
||||
console.log('开始播放,记录当前播放的语音id', body.lock);
|
||||
setPlayNumber(body.lock)
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
console.log('其他消息', msgType, body);
|
||||
break;
|
||||
@@ -112,6 +128,7 @@ export default function useWebSocket(aaas = null, options = {}) {
|
||||
data
|
||||
});
|
||||
}
|
||||
|
||||
const close = () => {
|
||||
ws.value.close({
|
||||
code: 1000,
|
||||
|
||||
Reference in New Issue
Block a user