Skip to main content

Simple presence boilerplate for django-channels 2 and channel redis backend.

Project description

**django-channels-presence2**

Simple presence boilerplate for django-channels 2 and channel redis backend.

**Installation**

`pip install django-channels-presence2`

**Usage**

Create presence for consumer:

`self.presence = await ChannelPresence.create_from_consumer(self, groups=(PUBLICATIONS_SCHEDULE_GROUP,))`

Example of create:

`class Consumer(AsyncJsonWebsocketConsumer):
async def connect(self):
self.presence = await ChannelPresence.create_from_consumer(self, groups=(CONSUMER_GROUP,))`

Groups are needed to send join and leave messages.
Learn more about groups: http://channels.readthedocs.io/en/latest/topics/channel_layers.html?highlight=group_send.

Join user:

`await self.presence.join()`

Leave user:

`await self.presence.leave()`

Get users:

`await self.presence.get_users(GROUP)`

Return:

`{
'user': SimpleLazyObject of User,
'is_active': True or False
'present_at': Datetime
}`

To set the activity expired time use `EXPIRED_USER_ACTIVITY` in django settings.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-channels-presence2-0.0.4a0.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file django-channels-presence2-0.0.4a0.tar.gz.

File metadata

File hashes

Hashes for django-channels-presence2-0.0.4a0.tar.gz
Algorithm Hash digest
SHA256 c0f13715b6132b6a1df286aaad83c267f1ba9c3753e69a3631a11b443bb6a401
MD5 79597c7c2b632af3d200437512de8f6b
BLAKE2b-256 fcb27eea01b596eca94c30adefea53daf06080f6d122394f5c05404d31c2dabf

See more details on using hashes here.

File details

Details for the file django_channels_presence2-0.0.4a0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_channels_presence2-0.0.4a0-py3-none-any.whl
Algorithm Hash digest
SHA256 3ada1e92d692f780191ab9332c543fba8754a816d96a98523fb04fce79f59958
MD5 f77fe239d478b711f722d41fc339f397
BLAKE2b-256 2fe177c1f82cc5c573c893ee671794a3eb764c7ba3efb10f66a1a6d473a9f756

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page