I'm a Rails beginner building a quiz webapp. Currently I'm using ActionCable.server.connections.length
to display how many people are connected to my quiz, but there are multiple problems:
- When the page is reloaded half of the time the old connection is not disconnected properly by ActionCable, so the number keeps rising even though it shouldn't
- it only gives you the current number of connections for the specific thread this is called in, as @edwardmp pointed out in this actioncable-how-to-display-number-of-connected-users thread (which also means, that the number of connections displayed for the quiz hoster, which is one type of user in my app, can vary from the number of connections displayed to a quiz participant)
- When a user connects with multiple browser windows each connection is counted seperately which falsely inflates the number of participants
- And last but not least: it would be great to be able to display the number of people connected per room of my channel, instead of across all rooms
I've noticed that most answers concerning this topic use a Redis server, so I was wondering if that is generally recommended for what I'm trying to do and why. (e.g. here: Actioncable connected users list )
I currently use Devise and cookies for my authentication.
Any pointers or answers to even part of my questions would be greatly appreciated :)