olahol/melody

Support for rooms

dangodai opened this issue · 1 comments

Has support for rooms been considered?

As of now it seems the way to do rooms is to set keys on a Session and use BroadcastFilter to broadcast to a room. Perhaps this is unfounded, but it seems like this could lead to poor performance since every Session is iterated over to check the filter.

Suggestions:
The list of rooms could look like map[string]map[*Session]bool
Thus broadcasting to a room would only have to iterate over those actually in the room.

However, disconnecting would require iterating over all rooms to check for the Session OR each Session would also have to maintain a list of rooms they are in. I think the second option may be favourable if people would be interesting in seeing what room a Session is in easily.

Thoughts?

I want to keep the interface of Melody as small as possible, I think rooms can be implemented by saving sessions to an external data structure.