Skip to content

Commit

Permalink
Repeat the connecting state when a gun crash occurs
Browse files Browse the repository at this point in the history
  • Loading branch information
ziopio committed May 30, 2024
1 parent 6b58bb8 commit e76c165
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/grisp_connect_client.erl
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,18 @@ handle_event(enter, _OldState, connecting, _Data) ->
{ok, Port} = application:get_env(grisp_connect, port),
?LOG_NOTICE(#{event => connecting, domain => Domain, port => Port}),
grisp_connect_ws:connect(Domain, Port),
{keep_state_and_data, [{state_timeout, 0, retry}]};
handle_event(state_timeout, retry, connecting, Data) ->
{keep_state_and_data, [{state_timeout, 0, wait}]};
handle_event(state_timeout, wait, connecting, Data) ->
case grisp_connect_ws:is_connected() of
true ->
?LOG_NOTICE(#{event => connected}),
{next_state, connected, Data};
false ->
?LOG_INFO(#{event => waiting_ws_connection}),
{keep_state_and_data, [{state_timeout, ?STD_TIMEOUT, retry}]}
{keep_state_and_data, [{state_timeout, ?STD_TIMEOUT, wait}]}
end;
handle_event(cast, disconnected, connecting, _Data) ->
repeat_state_and_data;

% CONNECTED
handle_event(enter, _OldState, connected, _Data) ->
Expand Down

0 comments on commit e76c165

Please sign in to comment.