django channels 2和channel redis后端的简单存在模板。
django-channels-presence2的Python项目详细描述
**django-channels-presence 2**
django channels 2和channel redis后端的简单显示样板。
**安装**
`pip安装django-channels-presence 2`
**用法**
groups=(publications_schedule_group,)`
创建示例:
`class consumer(asyncjsonwebsocketconsumer):
async def connect(self):
self.presence=await channelpresence.create_from_consumer(self,groups=(consumer_group,))`
发送加入和离开消息需要组。
了解有关组的更多信息:http://channels.readthedocs.io/en/latest/topics/channel\u layers.html?highlight=群组发送。
加入用户:
`await self.presence.join()`
leave用户:
`await self.presence.leave()`
get用户:
`await self.presence.get用户(组)`
return:
`{
`user':用户的simplelazyObject,
“is_active”:true或false
“present_at”:datetime
}`
要设置活动过期时间,请使用django设置中的“expired_user_activity”。
django channels 2和channel redis后端的简单显示样板。
**安装**
`pip安装django-channels-presence 2`
**用法**
groups=(publications_schedule_group,)`
创建示例:
`class consumer(asyncjsonwebsocketconsumer):
async def connect(self):
self.presence=await channelpresence.create_from_consumer(self,groups=(consumer_group,))`
发送加入和离开消息需要组。
了解有关组的更多信息:http://channels.readthedocs.io/en/latest/topics/channel\u layers.html?highlight=群组发送。
加入用户:
`await self.presence.join()`
leave用户:
`await self.presence.leave()`
get用户:
`await self.presence.get用户(组)`
return:
`{
`user':用户的simplelazyObject,
“is_active”:true或false
“present_at”:datetime
}`
要设置活动过期时间,请使用django设置中的“expired_user_activity”。