0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 12:20:24 +00:00

Update examples to the new interface

This commit is contained in:
Loïc Hoguin 2016-08-10 14:33:43 +02:00
parent 00f3ae7d20
commit ae95e87eb1
5 changed files with 11 additions and 11 deletions

View file

@ -7,14 +7,14 @@
-export([info/3]).
init(Req, Opts) ->
Req2 = cowboy_req:chunked_reply(200, #{
cowboy_req:stream_reply(200, #{
<<"content-type">> => <<"text/event-stream">>
}, Req),
erlang:send_after(1000, self(), {message, "Tick"}),
{cowboy_loop, Req2, Opts, 5000}.
{cowboy_loop, Req, Opts, 5000}.
info({message, Msg}, Req, State) ->
cowboy_req:chunk(["id: ", id(), "\ndata: ", Msg, "\n\n"], Req),
cowboy_req:stream_body(["id: ", id(), "\ndata: ", Msg, "\n\n"], nofin, Req),
erlang:send_after(1000, self(), {message, "Tick"}),
{ok, Req, State}.