[*] 日常优化

This commit is contained in:
acgist
2023-06-27 08:31:46 +08:00
parent 0ae5309b62
commit 8245d3446a
4 changed files with 57 additions and 47 deletions

View File

@@ -102,7 +102,7 @@ export default {
this.audioStream.addTrack(track);
this.audio.srcObject = this.audioStream;
}
this.audio.play().catch((error) => console.warn("频播放失败", error));
this.audio.play().catch((error) => console.warn("频播放失败", error));
} else if(track.kind === 'video') {
this.videoConsumer = consumer;
if (this.videoStream) {

View File

@@ -99,7 +99,7 @@ export default {
this.audioStream.addTrack(track);
this.audio.srcObject = this.audioStream;
}
this.audio.play().catch((error) => console.warn("频播放失败", error));
this.audio.play().catch((error) => console.warn("频播放失败", error));
} else if(track.kind === 'video') {
if (this.videoStream) {
// TODO资源释放

View File

@@ -601,11 +601,18 @@ class Taoyao extends RemoteClient {
async request(message) {
const me = this;
return new Promise((resolve, reject) => {
let done = false;
const { header, body } = message;
const { id } = header;
// 设置超时
const rejectTimeout = setTimeout(() => {
me.callbackMapping.delete(id);
reject("请求超时", message);
}, 5000);
// 请求回调
me.callbackMapping.set(message.header.id, (response) => {
me.callbackMapping.set(id, (response) => {
resolve(response);
done = true;
clearTimeout(rejectTimeout);
// 默认不用继续处理
return true;
});
// 发送消息
@@ -614,13 +621,6 @@ class Taoyao extends RemoteClient {
} catch (error) {
reject("同步请求异常", error);
}
// 设置超时
setTimeout(() => {
if (!done) {
me.callbackMapping.delete(message.header.id);
reject("请求超时", message);
}
}, 5000);
});
}
/************************ 回调 ************************/
@@ -939,8 +939,8 @@ class Taoyao extends RemoteClient {
* @param {*} message 消息
*/
defaultClientRegister(message) {
const { index } = message.body;
protocol.clientIndex = index;
protocol.clientIndex = message.body.index;
console.debug("终端序号", protocol.clientIndex);
}
/**
* 关闭终端信令