https://stackoverflow.com/a/36230416/5381547
https://stackoverflow.com/a/32945949/5381547
Those answers don't help me.
I want to get a list of all registered connections to my ActionCable. I tried
Redis.new.pubsub("channels", "action_cable/*")
and
ActionCable.server.connections.length,
but they both return []. So for now I'm using something like
def connect
self.uuid = SecureRandom.uuid
players_online = REDIS.get('players_online') || 0
players_online = players_online.to_i
players_online += 1
REDIS.set('players_online', players_online)
end
def disconnect
players_online = REDIS.get('players_online').to_i
players_online -= 1
REDIS.set('players_online', players_online)
end
But I know that this is a totally non Rails-way. Is there any possibility to get a list of all registered connections?