Hi,
We have a usecase where we want to know the number of times a user has joined a particular room.
There are couple of ways like maintaining a userId->count map in room variable/session and update it on user join room event.
But, wanted to check with you if there is an inbuilt-way to get that?
Thanks!
How to get the number of times a user has joined a given room?
-
- Posts: 16
- Joined: 09 Jun 2021, 07:23
Re: How to get the number of times a user has joined a given room?
Hi,
there is no pre-built functionality like the one you have described.
It's a good idea, but there can be side effects. If Rooms are persistent (i.e. they are never removed) you will need to keep track of Users leaving the server and remove their entry in the map that keeps count. Otherwise you'll end up with an ever-growing table of associations.
Other than that the idea of using a map seems good. I would probably recommend using AtomicIntegers to keep count, so that you don't have to worry about concurrent updates.
Cheers
there is no pre-built functionality like the one you have described.
There are couple of ways like maintaining a userId->count map in room variable/session and update it on user join room event.
It's a good idea, but there can be side effects. If Rooms are persistent (i.e. they are never removed) you will need to keep track of Users leaving the server and remove their entry in the map that keeps count. Otherwise you'll end up with an ever-growing table of associations.
Other than that the idea of using a map seems good. I would probably recommend using AtomicIntegers to keep count, so that you don't have to worry about concurrent updates.
Cheers
Who is online
Users browsing this forum: No registered users and 139 guests