mirror of
https://github.com/django/daphne.git
synced 2025-07-16 10:52:17 +03:00
Add paragraph on updating routing.py at that point
This commit is contained in:
parent
dfef0c551e
commit
3576267be2
|
@ -365,6 +365,18 @@ name in the path of your WebSocket request (we'll ignore auth for now - that's n
|
|||
def ws_disconnect(message):
|
||||
Group("chat-%s" % message.channel_session['room']).discard(message.reply_channel)
|
||||
|
||||
Update ``routing.py`` as well::
|
||||
|
||||
# in routing.py
|
||||
from channels.routing import route
|
||||
from myapp.consumers import ws_connect, ws_message, ws_disconnect
|
||||
|
||||
channel_routing = [
|
||||
route("websocket.connect", ws_connect),
|
||||
route("websocket.receive", ws_message),
|
||||
route("websocket.disconnect", ws_disconnect),
|
||||
]
|
||||
|
||||
If you play around with it from the console (or start building a simple
|
||||
JavaScript chat client that appends received messages to a div), you'll see
|
||||
that you can set a chat room with the initial request.
|
||||
|
|
Loading…
Reference in New Issue
Block a user