diff --git a/Makefile b/Makefile index 873c1eb..9f6cb94 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ PROJECT = wsio PROJECT_DESCRIPTION = WebSocket IO -PROJECT_VERSION = 0.1.0 +PROJECT_VERSION = 0.2.0 # By default templates indent with a single tab per indentation # level. Set this variable to the number of spaces you prefer: diff --git a/src/wsio_handler.erl b/src/wsio_handler.erl index ee3a215..7207d7e 100644 --- a/src/wsio_handler.erl +++ b/src/wsio_handler.erl @@ -40,9 +40,12 @@ websocket_info({send, <>}, S) -> {[{text, Bin}], S}; websocket_info({send, List}, S) when is_list(List) -> {List, S}; +websocket_info({'DOWN', _, process, PID, _}, #{wsbus := PID} = S) -> + {ok, S#{wsbus => nil, ref_wsbus => st:lookup(wsbus)}}; websocket_info({_, {Ref, {error, notfound}}}, #{ref_wsbus := Ref} = S) -> {ok, S#{ref_wsbus => st:lookup(wsbus)}}; websocket_info({_, {Ref, {ok, PID}}}, #{ref_wsbus := Ref} = S) -> + erlang:monitor(process, PID), {ok, maps:remove(ref_wsbus, S#{wsbus => PID})}; websocket_info(_, S) -> {ok, S}.