Skip to content

Commit

Permalink
server_sent_events: end gen_server process if send fails
Browse files Browse the repository at this point in the history
  • Loading branch information
vinoski committed Jul 12, 2012
1 parent 6c6f62f commit 2ad166a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions examples/src/server_sent_events.erl
Expand Up @@ -61,8 +61,14 @@ handle_info({discard, _YawsPid}, State) ->
handle_info(tick, #state{sock=Socket}=State) ->
Time = erlang:localtime(),
Data = yaws_sse:data(httpd_util:rfc1123_date(Time)),
yaws_sse:send_events(Socket, Data),
{noreply, State};
case yaws_sse:send_events(Socket, Data) of
ok ->
{noreply, State};
{error, closed} ->
{stop, normal, State};
{error, Reason} ->
{stop, Reason, State}
end;
handle_info({tcp_closed, _}, State) ->
{stop, normal, State#state{sock=closed}};
handle_info(_Info, State) ->
Expand Down

0 comments on commit 2ad166a

Please sign in to comment.