主动关闭信道

This commit is contained in:
2023-09-30 23:27:26 +08:00
parent 5a34c586ca
commit 1acb6f9f6b
1 changed files with 2 additions and 0 deletions

View File

@ -51,6 +51,7 @@
if (buffer.byteLength >= item.size) { if (buffer.byteLength >= item.size) {
console.log('音乐数据接收完毕') console.log('音乐数据接收完毕')
item.arrayBuffer = buffer item.arrayBuffer = buffer
event.target.close() // 关闭信道
resolve() resolve()
} }
} }
@ -132,6 +133,7 @@
} }
await sendChunk(ch, item.arrayBuffer) await sendChunk(ch, item.arrayBuffer)
console.log(`发送 ${channel} 信道数据结束`) console.log(`发送 ${channel} 信道数据结束`)
ch.close() // 关闭信道
} }
}) })
return return