mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-07-23 22:39:45 +03:00
channels getting started app
This commit is contained in:
parent
90301e190e
commit
9cd448012a
|
@ -0,0 +1,17 @@
|
||||||
|
"""
|
||||||
|
This is an example for a channels app using the getting started guide at
|
||||||
|
https://channels.readthedocs.org/en/latest/getting-started.html
|
||||||
|
"""
|
||||||
|
from channels import Group
|
||||||
|
|
||||||
|
# Connected to websocket.connect and websocket.keepalive
|
||||||
|
def ws_add(message):
|
||||||
|
Group("chat").add(message.reply_channel)
|
||||||
|
|
||||||
|
# Connected to websocket.receive
|
||||||
|
def ws_message(message):
|
||||||
|
Group("chat").send(message.content)
|
||||||
|
|
||||||
|
# Connected to websocket.disconnect
|
||||||
|
def ws_disconnect(message):
|
||||||
|
Group("chat").discard(message.reply_channel)
|
Loading…
Reference in New Issue
Block a user