Docs: Update encode/decode methods in example.

`encode` is now `channel_encode`, and `decode` is now `channel_decode`.
This commit is contained in:
George Brocklehurst 2016-02-07 10:19:21 -05:00
parent 88d3379e31
commit 85bb8c98d2
No known key found for this signature in database
GPG Key ID: 0C643A97B51FFCFB

View File

@ -109,11 +109,11 @@ message. Suddenly, a view is merely another example of a consumer::
# Listens on http.request # Listens on http.request
def my_consumer(message): def my_consumer(message):
# Decode the request from JSON-compat to a full object # Decode the request from JSON-compat to a full object
django_request = Request.decode(message.content) django_request = Request.channel_decode(message.content)
# Run view # Run view
django_response = view(django_request) django_response = view(django_request)
# Encode the response into JSON-compat format # Encode the response into JSON-compat format
message.reply_channel.send(django_response.encode()) message.reply_channel.send(django_response.channel_encode())
In fact, this is how Channels works. The interface servers transform connections In fact, this is how Channels works. The interface servers transform connections
from the outside world (HTTP, WebSockets, etc.) into messages on channels, from the outside world (HTTP, WebSockets, etc.) into messages on channels,