列出连接到django-channels组(通道1.x)的用户

时间:2019-08-09 03:46:13

标签: python django websocket django-channels

因此,我可以找到group_channels函数,但这似乎不存储用户信息。示例:

channel_layer = get_channel_layer()
context['players_list'] = channel_layer.group_channels('lobby')

我得到{'players_list': ['daphne.response.WbZyUfNixL!sbzfJEzdPp', 'daphne.response.KfDHQnHLdw!DpoOqdGute', 'daphne.response.JqlcVVMuny!xHLDSaCzUz', 'daphne.response.mWrYVXDKoI!AjkyadSsPe']}作为回应。

如何列出连接到Group('lobby')的用户?预先感谢

1 个答案:

答案 0 :(得分:0)

您已找到解决方案的正确方法,这就是解决方案的实际方法。也许您所缺少的是向使用者添加了正确的过程,因此它添加了所需的数据。

django-channels v.2.x中,使用者自动包含此信息,但是您必须在v.1.x中手动添加该信息,并在通用使用者中使用该修饰符或适当的声明,例如in the documentation进行了解释。