From caadd67b6899f26f4990f3bece950e21916a1414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A7=89?= Date: Sun, 22 Oct 2023 16:08:42 +0800 Subject: [PATCH] =?UTF-8?q?DEBUG:=20ICE=20=E8=BF=9E=E6=8E=A5=E7=8A=B6?= =?UTF-8?q?=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/client.js b/src/client.js index 66f0c23..6af76b0 100644 --- a/src/client.js +++ b/src/client.js @@ -95,18 +95,18 @@ export default class ClientList { option.onmessage(event, client) } } - //channel.onclose = event => { - // console.debug('对方关闭', channel.label, '数据通道') - // if (option && option.onclose) { - // option.onclose(event, client) - // } - //} - //channel.onerror = event => { - // console.error(data.name, '通道', channel.label, '发生错误') - // if (option && option.onerror) { - // option.onerror(event, client) - // } - //} + channel.onclose = event => { + console.debug('对方关闭', channel.label, '数据通道') + if (option && option.onclose) { + option.onclose(event, client) + } + } + channel.onerror = event => { + console.error(data.name, '通道', channel.label, '发生错误') + if (option && option.onerror) { + option.onerror(event, client) + } + } } webrtc.onicecandidate = event => { if (event.candidate) { @@ -118,9 +118,10 @@ export default class ClientList { } } webrtc.oniceconnectionstatechange = async event => { + console.log(data.name, 'ICE 连接状态:', webrtc.iceConnectionState) if (webrtc.iceConnectionState === 'disconnected' || webrtc.iceConnectionState === 'failed') { const client = this.clientlist.find(x => x.id === data.id) ?? {} - console.error(data.name, '需要添加新的 candidate', client.online) + console.error(data.name, '需要添加新的 candidate', webrtc.iceConnectionState, client.online) // 添加新的 candidate } else if (webrtc.iceConnectionState === 'connected' || webrtc.iceConnectionState === 'completed') { //console.debug(data.name, 'WebRTC 连接已经建立成功')