How to group multiple users properly?

Hello!!

I’m trying to build an application that allows users to interact with a shared document, but depending on their role they will have access to a different set of shared documents.

So far I’ve done this by defining a different room for each role, but I’ve noticed that If I don’t disconnect the user from this room and enter another room the contents end up overlapping each other.

Something Like this:

room A → content A
room B → content B

When I don’t disconnect
room A → content B
room B → content B

I fix this issue by making sure that the user disconnects whenever he leaves the page, but I’m not confident that this problem won’t happen again.
That’s why I want to know why this happened and if this is the right way of doing it.
That’s how I’m doing It
Captura de tela 2024-01-29 085608

Hi. Are you explicitly calling provider.destroy() on the old provider instance when the room changes? Otherwise it seems like the connection could persist.

Also make sure to create a new Doc instance for the new room. Docs are not designed to be containers for content that can be switched in and out.

On a different note, the room system is somewhat limited as an authentication system. It is essentially just a “secret” url, so there is no way to unshare or change a user’s role. It is possible to generate a new room every time anyone’s role is revoked, but then you have to distribute that new room to all remaining participants. A server-side authentication system seems more flexible. Not sure what your requirements are though :).

Thanks for the reply.

Are you explicitly calling provider.destroy() on the old provider instance when the room changes?

No, I wasn’t. The data displayed on the console corresponds to the two rooms, but the content was not