diff --git a/src/client.js b/src/client.js index e0bf2ad..e02750e 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) { @@ -136,6 +136,11 @@ export default class ClientList { }) return dc }) + //// 页面刷新前主动关闭所有数据通道并关闭 WebRTC 连接 + //window.addEventListener('beforeunload', event => { + // channels.forEach(ch => ch.close()) + // webrtc.close() + //}) return { webrtc, channels } } if (data.type === 'list') {