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.
Yeah that's possible. And the easy hack is...
# Get channel_layer function
from channels.asgi import get_channel_layer
# passing group_channel takes channel name
channel_layer = get_channel_layer()
ch_group_list = channel_layer.group_channels('<your group name>')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With