yjs / y-webrtc

WebRTC Connector for Yjs
MIT License
458 stars 111 forks source link

filterBcConns = true doesn't work #10

Closed areebbeigh closed 4 years ago

areebbeigh commented 4 years ago

Using filterBcConns: true in options still uses broadcast channels instead of a webrtc connection for tabs in the same browser. Tested on Chrome: Version 79.0.3945.79 (Official Build) (64-bit) and Firefox: 74.0 (64-bit) on Ubuntu 18.04

diegodorado commented 4 years ago

the same happens to me. I believe the option should be disableBroadcastChannels and do not even subscribe/unsuscribe on connect/disconnect

areebbeigh commented 4 years ago

I suppose I wasn't paying enough attention. filterBcConns: false ~is what makes sense~ is what works if I want browser tabs to use webRTCConns. I think the readme has it wrong.

That, or the default value in the constructor is should be false, not true - which makes more sense since filterBcConns is basically hypothetical !allowBcConns?

dmonad commented 4 years ago

All Yjs connectors use broadcastchannels to exchange document updates efficiently window-to-window. It is a cheap method to exchange document updates when no internet connection is available.

It doesn't make sense to me to disable the broadcastchannel (there is no advantage in that). Creating a webrtc connection instead of a broadcastchannel will just delay syncing. Furthermore, it is not possible to create WebRTC connection without a network connection.

The idea is that a WebRTC connection is only created if the client is not already connected via broadcastchannel. Therefore, filterBcConns.

But you are right @areebbeigh . The mentioned section is wrong.