diff --git a/public/index.html b/public/index.html index 978f945..83698f1 100644 --- a/public/index.html +++ b/public/index.html @@ -95,7 +95,7 @@ const { type, id, channel, list } = JSON.parse(event.data) console.log('收到 base 基本信道数据:', type, id, channel) if (type === 'get_music_list') { - console.log('发送音乐列表:', musicList.list) + console.log(client.name, '请求音乐列表:', musicList.list) clientList.send('base', JSON.stringify({ type: 'set_music_list', list: musicList.list.map(({ id, name, size, type }) => ({ id, name, size, type })) @@ -103,7 +103,7 @@ return } if (type === 'set_music_list') { - console.log('接收音乐列表:', event) + console.log(client.name, '发来音乐列表:', event) // 将音乐列表添加到本地 const ids = musicList.list.map(item => item.id) list.filter(item => !ids.includes(item.id)).forEach(item => { @@ -113,11 +113,11 @@ } if (type === 'get_music_data') { // 建立一个信道, 用于传输音乐数据(接收方已经准备好摘要信息) - console.log('建立一个信道, 用于传输音乐数据', musicList.list) + console.log(client.name, '建立一个信道, 用于传输音乐数据', musicList.list) musicList.list.filter(item => item.id === id).forEach(item => { const ch = client.webrtc.createDataChannel(channel, { reliable: true }) ch.onopen = async event => { - console.log(`打开 ${channel} 信道, 传输音乐数据`) + console.log(client.name, `打开 ${channel} 信道, 传输音乐数据`) // 将音乐数据分成多个小块,并逐个发送 async function sendChunk(dataChannel, data, index = 0, buffer = new ArrayBuffer(0)) { while (index < data.byteLength) {