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.0.tar.gz
(4.0 kB
view hashes)
Built Distribution
Close
Hashes for channels_easy-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e85d26dec81faac3d74b011abf99bc5bf4d3ff1fc3a87c4edc15a23ed55e8259 |
|
MD5 | 904b3c4ef4ee4b32cff9eb4a2f470a9e |
|
BLAKE2b-256 | b8c9432c9d46de32c998f28a43cc07483f1c0148d81f26481ca6ff5b5ff7a38e |