Channels has to be one of the great libs I've used. However didn't find enough examples on how to implement long polling.
So according to my understanding is that when request is received the "LongPollConsumer" consumer handler function send a "don't close body" by using more_body=True param.
-- So according to my understanding is that when request is received the "LongPollConsumer" consumer handler function send a "don't close body" by using more_body=True param.
Often during WebSockets the "group.send" is not implemented on the consumer rather outside.When using long poll how can i get the *request to send a response back to the client and close it assuming am outside the consumer?
import json from channels.generic.http import AsyncHttpConsumer class LongPollConsumer(AsyncHttpConsumer): async def handle(self, body): await self.send_headers(headers=[ ("Content-Type", "application/json"), ]) await self.send_body(b"", more_body=True) async def chat_message(self, event): await self.send_body(json.dumps(event).encode("utf-8"))
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9cd350b4-f840-4cd7-9954-d8a42a1ed8b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment