I want users to collaborate on different documents via peer-to-peer communication (y-webrtc).
My understanding is that I need to create a different room for each document. In this setup, when a user switches from one document to another, they would to have to change the room.
I couldn’t find an option to change the room in the WebrtcProvider. So, I figured that I might have to create a new WebrtcProvider whenever the user switches to another document (
webrtc = webrtcProvider(documentId, new Doc());).
Yet, when I do this, I receive these errors:
Error: A Yjs Doc connected to room "document1" already exists! at Module.create (error.js:12) at openRoom (y-webrtc.js:437) at y-webrtc.js:574
Looking through the code, I see that y-webrtc remembers the room, and prevent to subscribe multiple times to the same room. Yet, I don’t really understand how to switch the room (or how to subscribe to multiple room and figure out for which room data in a
change event is).
I’d highly appreciate a pointer on how to handle this?
Thanks a lot!