Is it possible to access the list of channels added in a Group with django-channels?
def consumer(message):
Group("group_name").add(message.reply_channel)
channel_list = Group("group_name").???
EDIT:
What I try to achieve is to have access to sessions of all channel, like the list of connected users for instance.
Thus far I use a database based system that lists the connections. But if the server shuts down without executing my ws_disconnect consumers, these connections object will remain in database, and I don't want this.
EDIT 2:
To list the connected users, I found django-channels-presence
. I'll test it.
I've tested django-channels-presence
and I easily succeeded to list the connected users for a Group
by creating a Room
(that handle Group
management/creation, channel
adding/removing...) and that provides a get_users()
method that permits me to achieve what I was searching for.
It also provides a way to clean added channels that aren't deleted if the server crashes (that wouldn't trigger the ws_disconnect consumer that is used to delete these channels from the group). It provides the prune_presence
and prune_room
tasks that cleans expired channels.