channels getting started app

This commit is contained in:
Jay 2016-01-08 14:01:20 +01:00
parent 90301e190e
commit 9cd448012a
2 changed files with 17 additions and 0 deletions

View File

@ -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)