John
John

Reputation: 85

Django Channels 2: How Many Users Is In The Specific Room

I am using django-channels>=2.0.0 and I want to find how many users in "room1". I don't know how to find total connections.

Upvotes: 4

Views: 1671

Answers (1)

drec4s
drec4s

Reputation: 8077

Using the InMemoryChannelLayer, inside your consumer, you can check how many connections have been added to your channel layer with :

len(self.channel_layer.groups.get('room1', {}).items())

Upvotes: 0

Related Questions