stefanw / channels-yroom

Django Channels WebSocket consumer and worker for synchronizing Yjs clients
https://channels-yroom.readthedocs.io/en/latest/
MIT License
15 stars 5 forks source link

Simplify naming room #2

Closed linspw closed 1 year ago

linspw commented 1 year ago

The idea of ​​this Pull Request is to simplify the way the room name is created for the developer, I imagine that it will most likely be used the value passed n kwargs and a prefix in the room name.

stefanw commented 1 year ago

I would not include the url kwarg or a prefix as a default. Requirements of users might be so different, some may just need one single room. If you need a specific name, you should overwrite the method. I changed the method name to just be get_room_name:

class YroomConsumer(AsyncWebsocketConsumer):
    room_name = "yroom_default"

    def get_room_name(self) -> str:
        """Returns the name of the room group to join.
            This represents the room that the client is joining.

        Returns:
            str: room group name
        """
        return self.room_name