Closed janhohenheim closed 2 years ago
You could do something like sending a room_id with each message, and then having clients ignore messages from other rooms or having the server keep track of which connection has which room_id.
You mean sending messages to exactly those clients that have the room_id instead of broadcasting?
You mean sending messages to exactly those clients that have the room_id instead of broadcasting?
Exactly that, yea. You'd of course have to store some sort of state on. The server, but I don't imagine it would be too difficult. A hash map woth the room id as a key and the client id's in said room as a value would likely be enough.
Is there some kind of default way / batteries included way of implementing rooms? i.e. let clients connect to a room and only receive messages sent to that room. I suspect the channel ID might be useful for this?