This commit is contained in:
turtled 2016-12-13 15:57:22 +08:00
parent 8c1f5d7ec1
commit 696647f2cf
1 changed files with 8 additions and 0 deletions

View File

@ -62,6 +62,7 @@ unsubscribe(CPid, Topics) ->
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
init([MqttEnv, WsPid, Req, ReplyChannel]) -> init([MqttEnv, WsPid, Req, ReplyChannel]) ->
process_flag(trap_exit, true),
true = link(WsPid), true = link(WsPid),
{ok, Peername} = Req:get(peername), {ok, Peername} = Req:get(peername),
Headers = mochiweb_headers:to_list( Headers = mochiweb_headers:to_list(
@ -171,6 +172,13 @@ handle_info({keepalive, check}, State = #wsclient_state{peer = Peer,
shutdown(keepalive_error, State) shutdown(keepalive_error, State)
end; end;
handle_info({'EXIT', WsPid, normal}, State = #wsclient_state{ws_pid = WsPid}) ->
stop(normal, State);
handle_info({'EXIT', WsPid, Reason}, State = #wsclient_state{peer = Peer, ws_pid = WsPid}) ->
?WSLOG(error, Peer, "shutdown: ~p",[Reason]),
shutdown(Reason, State);
handle_info(Info, State = #wsclient_state{peer = Peer}) -> handle_info(Info, State = #wsclient_state{peer = Peer}) ->
?WSLOG(critical, Peer, "Unexpected Info: ~p", [Info]), ?WSLOG(critical, Peer, "Unexpected Info: ~p", [Info]),
noreply(State). noreply(State).