mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Use cowboy_req:stream_events in the eventsource example
This commit is contained in:
parent
0fb68ec07f
commit
6b1db885d1
1 changed files with 4 additions and 1 deletions
|
@ -14,7 +14,10 @@ init(Req0, Opts) ->
|
|||
{cowboy_loop, Req, Opts}.
|
||||
|
||||
info({message, Msg}, Req, State) ->
|
||||
cowboy_req:stream_body(["id: ", id(), "\ndata: ", Msg, "\n\n"], nofin, Req),
|
||||
cowboy_req:stream_events(#{
|
||||
id => id(),
|
||||
data => Msg
|
||||
}, nofin, Req),
|
||||
erlang:send_after(1000, self(), {message, "Tick"}),
|
||||
{ok, Req, State}.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue