Skip to main content

A thin wrapper around channels consumer to make things EASY

Project description

channels-easy

A thin wrapper around channel consumers to make things EASY.

Installation

To get the latest stable release from PyPi

pip install channels-easy

To get the latest commit from GitHub

pip install -e git+git://github.com/namantam1/channels-easy.git#egg=channels-easy

As channels-easy is a thin wrapper around channels so channels must be in your INSTALLED_APPS in settings.py.

INSTALLED_APPS = (
    ...,
    'channels',
)

Usage

All the naming convention used to implement this library is inspired from socket.io to make server implementation simple.

# consumers.py
from channels_easy.generic import AsyncWebsocketConsumer


class NewConsumer(AsyncWebsocketConsumer):
    async def connect(self):
        # join room on connect
        await self.join("room1")
        await self.accept()

    async def disconnect(self, close_code):
        # Leave room on disconnect
        await self.leave("room1")

    async def on_message(self, data):
        print("message from client", data)
        await self.emit("message", "room1", {"message": "hello from server"})

Contribute

If you want to contribute to this project, please perform the following steps

# Fork this repository
# Clone your fork
poetry install

git checkout -b feature_branch master
# Implement your feature and tests
git add . && git commit
git push -u origin feature_branch
# Send us a pull request for your feature branch

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

channels-easy-0.2.1.tar.gz (4.2 kB view hashes)

Uploaded Source

Built Distribution

channels_easy-0.2.1-py3-none-any.whl (4.3 kB view hashes)

Uploaded Python 3

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