我试着辨别一条信息是通过哪两个渠道发出的,但我不知道如何区分它们.
我怎么能做到这一点呢?
let channel = null;
let channel2 = null;
channel = connection.createDataChannel('data');
channel2 = connection.createDataChannel('data2');
connection.ondatachannel = (event) => {
// I'm sure it's here, but I don't know how to tell the difference.
channel = event.channel;
channel2 = event.channel;
// Regardless of whether channel or channel2 is typed, the messages are mixed up.
channel.onmessage = (event) => {}
channel2.onmessage = (event) => {}
}