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 连接已经建立成功')