Open lazd opened 10 years ago
A workaround, in the mean time, is to use the simplewebrtc
data channel for all your data needs.
opening the simplewebrtc channel at that time is a workaround for the webrtc api which will only negotiate data channels if there was a data channel before the offer is created. The right thing to do is probably to set a "initiator" flag at the same time and only create data channels if you're the initiator. hm...
note that channel labels are not unique which breaks the assumption they're observable in the way it is currently done.
I have the following code in place on two peers:
The
chat
data channel actually opens twice because both peers open it at the same time. As a result, the data channel will actually just stop functioning after some time (without reporting that it has closed). If you examine what's going on, you can clearly see the data channel returned bypeer.getDataChannel('chat')
is not the same one being used by calls towebrtc.sendDirectlyToAll('chat', /*...*/)
.How can I ensure the data channel is opened only once? I see the
start
method inpeer.js
opens thesimplewebrtc
data channel, and it works out to only happen once, but there's no hook to add additional data channels at that time.