控制台调试日志优化

This commit is contained in:
2023-10-03 04:39:18 +08:00
parent c2350977e4
commit c5cd987d57
2 changed files with 5 additions and 1 deletions

View File

@ -55,6 +55,7 @@ export default class ClientList {
const option = this.channels[channel.label] const option = this.channels[channel.label]
channel.onopen = event => { channel.onopen = event => {
console.log('对方打开', channel.label, '数据通道') console.log('对方打开', channel.label, '数据通道')
console.group('收到音乐数据')
if (option && option.onopen) { if (option && option.onopen) {
option.onopen(event, client) option.onopen(event, client)
} }
@ -66,6 +67,7 @@ export default class ClientList {
} }
} }
channel.onclose = event => { channel.onclose = event => {
console.groupEnd('收到音乐数据')
console.log('对方关闭', channel.label, '数据通道') console.log('对方关闭', channel.label, '数据通道')
if (option && option.onclose) { if (option && option.onclose) {
option.onclose(event, client) option.onclose(event, client)

View File

@ -115,7 +115,7 @@
clientList.setChannel(`music-data-${item.id}`, { clientList.setChannel(`music-data-${item.id}`, {
onmessage: async (event, client) => { onmessage: async (event, client) => {
buffer = appendBuffer(buffer, event.data) buffer = appendBuffer(buffer, event.data)
console.log('收到音乐数据 chunk', count, buffer.byteLength) console.log('收到音乐数据 chunk', count, buffer.byteLength)
count++ count++
if (buffer.byteLength >= item.size) { if (buffer.byteLength >= item.size) {
console.log('音乐数据接收完毕') console.log('音乐数据接收完毕')
@ -162,7 +162,9 @@
console.log(client.name, '发来音乐列表:', `x${JSON.parse(event.data).list.length}`) console.log(client.name, '发来音乐列表:', `x${JSON.parse(event.data).list.length}`)
console.log('将列表保存到本机记录:', client) console.log('将列表保存到本机记录:', client)
client.musicList = list client.musicList = list
console.group('添加音乐')
client.musicList.forEach(music => musicList.add(music)) client.musicList.forEach(music => musicList.add(music))
console.groupEnd('添加音乐')
return return
} }
if (type === 'get_music_data') { if (type === 'get_music_data') {