Server-sent events #919
-
Is there a way to use server-sent events with uWebSockets? By sse I mean this. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I tried something along these lines:
|
Beta Was this translation helpful? Give feedback.
-
@Zxey in case you're still figuring this out, I wanted to use SSE to have live reload for blogging. ngzhian/blog@e76e964#diff-b388e57e18c6815f3bdd3a6412184385 is what I ended up with. I used uWebSockets to listen on 9001, when I do |
Beta Was this translation helpful? Give feedback.
@Zxey in case you're still figuring this out, I wanted to use SSE to have live reload for blogging. ngzhian/blog@e76e964#diff-b388e57e18c6815f3bdd3a6412184385 is what I ended up with.
I used uWebSockets to listen on 9001, when I do
curl localhost:9001
it sends a message to a connected session (by keeping the HttpResponse in a global object). The browser first establishes the connection by creating anew EventSource('http://localhost:9001/eventsource')
, see the same commit. So far it has worked okay for me.