fix
This commit is contained in:
parent
6d6a9c4585
commit
87874135aa
@ -134,10 +134,8 @@ handle_event(info, {timeout, _, create_transport}, ?STATE_DISCONNECTED, State =
|
||||
Ref = make_ref(),
|
||||
AuthPacket = auth_packet(Ref),
|
||||
ok = ssl:send(Socket, AuthPacket),
|
||||
{next_state, ?STATE_AUTH, State#state{socket = Socket, auth_ref = Ref},
|
||||
[{state_timeout, 5000, auth_timeout}]};
|
||||
{next_state, ?STATE_AUTH, State#state{socket = Socket, auth_ref = Ref}, [{state_timeout, 5000, auth_timeout}]};
|
||||
{error, _Reason} ->
|
||||
%logger:debug("[efka_client] connect failed"),
|
||||
schedule_reconnect(),
|
||||
{keep_state, State#state{socket = undefined}}
|
||||
end;
|
||||
@ -222,16 +220,13 @@ handle_event(internal, {request, Ref, {container_request, Request}}, _StateName,
|
||||
{keep_state, State};
|
||||
|
||||
%% 处理response
|
||||
handle_event(internal, {response, AuthRef, {auth_response, ok}},
|
||||
?STATE_AUTH, State = #state{auth_ref = AuthRef}) ->
|
||||
handle_event(internal, {response, AuthRef, {auth_response, ok}}, ?STATE_AUTH, State = #state{auth_ref = AuthRef}) ->
|
||||
logger:debug("[efka_client] auth success"),
|
||||
{next_state, ?STATE_ACTIVATED, State#state{auth_ref = undefined}, [{next_event, info, flush_cache}]};
|
||||
handle_event(internal, {response, AuthRef, {auth_response, {error, {denied, Message}}}},
|
||||
?STATE_AUTH, State = #state{auth_ref = AuthRef}) ->
|
||||
handle_event(internal, {response, AuthRef, {auth_response, {error, {denied, Message}}}}, ?STATE_AUTH, State = #state{auth_ref = AuthRef}) ->
|
||||
logger:debug("[efka_client] auth denied, message: ~p", [Message]),
|
||||
{next_state, ?STATE_RESTRICTED, State#state{auth_ref = undefined}};
|
||||
handle_event(internal, {response, AuthRef, {auth_response, {error, Reason}}},
|
||||
?STATE_AUTH, State = #state{socket = Socket, auth_ref = AuthRef}) ->
|
||||
handle_event(internal, {response, AuthRef, {auth_response, {error, Reason}}}, ?STATE_AUTH, State = #state{socket = Socket, auth_ref = AuthRef}) ->
|
||||
logger:debug("[efka_client] auth failed, reason: ~p", [Reason]),
|
||||
disconnect(Socket),
|
||||
schedule_reconnect(),
|
||||
@ -241,9 +236,7 @@ handle_event(internal, {response, _Ref, Reply}, StateName, State) ->
|
||||
{keep_state, State};
|
||||
|
||||
%% 处理命令
|
||||
handle_event(internal, {message, {auth_control, Cmd}},
|
||||
StateName, State = #state{socket = Socket}) ->
|
||||
|
||||
handle_event(internal, {message, {auth_control, Cmd}}, StateName, State = #state{socket = Socket}) ->
|
||||
logger:debug("[efka_client] auth cmd: ~p", [Cmd]),
|
||||
case {Cmd, StateName} of
|
||||
{activate, ?STATE_ACTIVATED} ->
|
||||
@ -252,8 +245,7 @@ handle_event(internal, {message, {auth_control, Cmd}},
|
||||
Ref = make_ref(),
|
||||
AuthPacket = auth_packet(Ref),
|
||||
ok = ssl:send(Socket, AuthPacket),
|
||||
{next_state, ?STATE_AUTH, State#state{auth_ref = Ref},
|
||||
[{state_timeout, 5000, auth_timeout}]};
|
||||
{next_state, ?STATE_AUTH, State#state{auth_ref = Ref}, [{state_timeout, 5000, auth_timeout}]};
|
||||
{deactivate, _} ->
|
||||
{next_state, ?STATE_RESTRICTED, State}
|
||||
end;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user