Closed t3ndai closed 4 years ago
Hi @t3ndai,
django-eventstream is a library that provides SSE endpoints.
django-grip is a library for interfacing with GRIP proxies.
Note: django-eventstream has optional GRIP support, which it implements using the django-grip library.
It looks like you're trying to implement SSE. In that case, django-eventstream may be easier to use, especially if you want extra conveniences. But either way works. SSE is a simple protocol, and implementing something basic with django-grip is pretty easy.
That "connected" string is not valid SSE-formatting though. Try:
HttpResponse("event: message\ndata: connected\n\n", content_type="text/event-stream")
Regarding CORS issues, you'll want to respond with the appropriate Access-Control-*
headers.
I hope that all makes sense.
@jkarneges thanks for your response. closing this out, though I have one question which is from django_eventstream import send_event
i.e send_event is basically sugar for the http response I have on the original post right ? and if I use send_event then for the http response, I just need to return that it's a event stream ?
I suppose you could say the send_event
function is like sugar for the HTTP response body, after the HTTP response code and headers have been sent.
But yeah, SSE requires basically two steps: 1) start a HTTP response with content type text/event-stream
that stays open, 2) send SSE-encoded events in the response body.
had started experimenting with django-grip. what's the difference between the two libraries ?
also getting cors issues currently with django-grip
my view to subscribe to something