清理调试信息

This commit is contained in:
2023-10-19 07:03:21 +08:00
parent edae22db79
commit 2c00cb8ef9
3 changed files with 20 additions and 20 deletions

View File

@ -154,7 +154,7 @@
// 只有一个基本信道, 用于交换和调度信息
clientList.setChannel('base', {
onopen: async event => {
console.debug('打开信道', event.target.label, '广播请求音乐列表和身份信息')
//console.debug('打开信道', event.target.label, '广播请求音乐列表和身份信息')
clientList.send('base', JSON.stringify({ type: 'get_music_list' })) // 要求对方发送音乐列表
clientList.send('base', JSON.stringify({ type: 'get_user_profile' })) // 要求对方发送身份信息
},

View File

@ -78,11 +78,11 @@ export default class ClientList {
}
})
webrtc.ondatachannel = ({ channel }) => {
console.debug(data.name, '建立', channel.label, '数据通道')
//console.debug(data.name, '建立', channel.label, '数据通道')
const client = this.clientlist.find(x => x.id === data.id)
const option = this.channels[channel.label]
channel.onopen = event => {
console.debug('对方打开', channel.label, '数据通道')
//console.debug('对方打开', channel.label, '数据通道')
if (option && option.onopen) {
option.onopen(event, client)
}
@ -120,7 +120,7 @@ export default class ClientList {
console.error(data.name, '需要添加新的 candidate')
// 添加新的 candidate
} else if (webrtc.iceConnectionState === 'connected' || webrtc.iceConnectionState === 'completed') {
console.debug(data.name, 'WebRTC 连接已经建立成功')
//console.debug(data.name, 'WebRTC 连接已经建立成功')
}
}
const channels = Object.entries(this.channels).map(([name, callback]) => {
@ -137,9 +137,9 @@ export default class ClientList {
return { webrtc, channels }
}
if (data.type === 'list') {
console.debug('取得在线对端列表:', data)
//console.debug('取得在线对端列表:', data)
const { webrtc, channels } = await webrtc_init()
console.debug('发送给对方 offer')
//console.debug('发送给对方 offer')
const offer = await webrtc.createOffer()
await webrtc.setLocalDescription(offer)
this.clientlist.push({ id: data.id, name: data.name, webrtc, channels })
@ -149,7 +149,7 @@ export default class ClientList {
return
}
if (data.type === 'push') {
console.debug('新上线客户端:', data)
//console.debug('新上线客户端:', data)
return
}
if (data.type === 'pull') {
@ -157,12 +157,12 @@ export default class ClientList {
return this.exit(data)
}
if (data.type === 'offer') {
console.debug('收到对方 offer', data)
//console.debug('收到对方 offer', data)
const { webrtc, channels } = await webrtc_init()
this.clientlist.push({ id: data.id, name: data.name, webrtc, channels })
// 传递正确的指针给元素, 以便其能够调取正确的头像
this.push(this.clientlist.find(client => client.id === data.id))
console.debug('发送给对方 answer')
//console.debug('发送给对方 answer')
await webrtc.setRemoteDescription(data.offer)
const answer = await webrtc.createAnswer()
await webrtc.setLocalDescription(answer)
@ -170,13 +170,13 @@ export default class ClientList {
return
}
if (data.type === 'answer') {
console.debug('收到对方 answer', data)
//console.debug('收到对方 answer', data)
const webrtc = this.clientlist.find(client => client.id === data.id).webrtc
await webrtc.setRemoteDescription(data.answer)
return
}
if (data.type === 'candidate') {
console.debug(data.name, '发来 candidate 候选通道')
//console.debug(data.name, '发来 candidate 候选通道')
const webrtc = this.clientlist.find(client => client.id === data.id).webrtc
await webrtc.addIceCandidate(data.candidate)
return
@ -227,11 +227,11 @@ export default class ClientList {
}
getAvatar(id) { }
setAvatar(user) {
console.info('更新avatar', user)
//console.info('更新avatar', user)
document.getElementById(user.id).querySelector('img').src = user.avatar
const u = this.clientlist.find(client => client.id === user.id)
u.avatar = user.avatar
console.log(u, user)
//console.log(u, user)
//.avatar = user.avatar
}
exit(item) {

View File

@ -85,20 +85,20 @@ const musicList = new MusicList({
}
},
onban: item => {
console.info('禁止音乐', item.name)
//console.info('禁止音乐', item.name)
},
onunban: item => {
console.info('解禁音乐', item.name)
//console.info('解禁音乐', item.name)
},
onremove: item => {
console.info('移除音乐', item.name)
//console.info('移除音乐', item.name)
musicStore.delete(item.id)
},
onadd: (item, list) => {
console.info('添加音乐', item.name)
//console.info('添加音乐', item.name)
},
onupdate: item => {
console.info('更新音乐', item.name)
//console.info('更新音乐', item.name)
musicStore.put(item)
},
onerror: error => {
@ -154,7 +154,7 @@ const chat = new Chat({
// 与每个客户端都建立聊天信道
clientList.setChannel('chat', {
onopen: async event => {
console.debug('打开信道', event.target.label)
//console.debug('打开信道', event.target.label)
},
onmessage: async (event, client) => {
const data = JSON.parse(event.data)
@ -268,7 +268,7 @@ clientList.setChannel('profile', {
// 与每个客户端都建立基本信道, 用于交换和调度信息
clientList.setChannel('base', {
onopen: async event => {
console.debug('打开信道', event.target.label, '广播请求音乐列表和身份信息')
//console.debug('打开信道', event.target.label, '广播请求音乐列表和身份信息')
clientList.send('base', JSON.stringify({ type: 'get_music_list' })) // 要求对方发送音乐列表
//clientList.send('base', JSON.stringify({ type: 'get_user_profile' })) // 要求对方发送身份信息
},