diff options
Diffstat (limited to 'examples/eventsource')
-rw-r--r-- | examples/eventsource/src/eventsource_handler.erl | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/examples/eventsource/src/eventsource_handler.erl b/examples/eventsource/src/eventsource_handler.erl index 4a30b9b..1276a75 100644 --- a/examples/eventsource/src/eventsource_handler.erl +++ b/examples/eventsource/src/eventsource_handler.erl @@ -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}. |