billyb2 / bootleg_networking

A cross platform (wasm included) networking library!
MIT License
56 stars 5 forks source link

Rooms #4

Closed janhohenheim closed 2 years ago

janhohenheim commented 2 years ago

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?

billyb2 commented 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.

janhohenheim commented 2 years ago

You mean sending messages to exactly those clients that have the room_id instead of broadcasting?

billyb2 commented 2 years ago

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.