version: 0.2.0

+ monitoring wsbus PID
This commit is contained in:
Umgeher Torgersen 2024-11-27 16:35:03 +00:00
parent 052b0b25c7
commit c98e8718a8
2 changed files with 4 additions and 1 deletions

View file

@ -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:

View file

@ -40,9 +40,12 @@ websocket_info({send, <<Bin/binary>>}, 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}.