控制台调试日志优化
This commit is contained in:
parent
6800b44e49
commit
3f1d86975b
@ -61,8 +61,8 @@ export default class ClientList {
|
|||||||
const client = this.clientlist.find(x => x.id === data.id)
|
const client = this.clientlist.find(x => x.id === data.id)
|
||||||
const option = this.channels[channel.label]
|
const option = this.channels[channel.label]
|
||||||
channel.onopen = event => {
|
channel.onopen = event => {
|
||||||
|
console.group('')
|
||||||
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)
|
||||||
}
|
}
|
||||||
@ -74,13 +74,14 @@ export default class ClientList {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
channel.onclose = event => {
|
channel.onclose = event => {
|
||||||
console.groupEnd('收到音乐数据')
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
channel.onerror = event => {
|
channel.onerror = event => {
|
||||||
|
console.groupEnd('')
|
||||||
console.log(data.name, '通道', channel.label, '发生错误')
|
console.log(data.name, '通道', channel.label, '发生错误')
|
||||||
if (option && option.onerror) {
|
if (option && option.onerror) {
|
||||||
option.onerror(event, client)
|
option.onerror(event, client)
|
||||||
|
@ -167,6 +167,7 @@
|
|||||||
// 只有一个基本信道, 用于交换和调度信息
|
// 只有一个基本信道, 用于交换和调度信息
|
||||||
clientList.setChannel('base', {
|
clientList.setChannel('base', {
|
||||||
onopen: async event => {
|
onopen: async event => {
|
||||||
|
console.group('')
|
||||||
console.log('打开信道', event.target.label)
|
console.log('打开信道', event.target.label)
|
||||||
// 要求对方发送音乐列表
|
// 要求对方发送音乐列表
|
||||||
clientList.send('base', JSON.stringify({ type: 'get_music_list' }))
|
clientList.send('base', JSON.stringify({ type: 'get_music_list' }))
|
||||||
@ -186,9 +187,7 @@
|
|||||||
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') {
|
||||||
@ -221,9 +220,11 @@
|
|||||||
console.log('未知类型:', type)
|
console.log('未知类型:', type)
|
||||||
},
|
},
|
||||||
onclose: event => {
|
onclose: event => {
|
||||||
|
console.groupEnd('')
|
||||||
console.log('关闭信道', event.target.label)
|
console.log('关闭信道', event.target.label)
|
||||||
},
|
},
|
||||||
onerror: error => {
|
onerror: error => {
|
||||||
|
console.groupEnd('')
|
||||||
console.log('信道错误', error)
|
console.log('信道错误', error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user