fix agent
This commit is contained in:
parent
a0724db88c
commit
a117d81fc6
@ -83,7 +83,7 @@ handle_event(info, {timeout, _, create_transport}, ?STATE_DENIED, State = #state
|
||||
{ok, TransportPid} = efka_transport:start_link(self(), Host, Port),
|
||||
efka_transport:connect(TransportPid),
|
||||
|
||||
{next_state, ?STATE_CONNECTING, State};
|
||||
{next_state, ?STATE_CONNECTING, State#state{transport_pid = TransportPid}};
|
||||
|
||||
%% 连接的回复
|
||||
handle_event(info, {connect_reply, Reply}, ?STATE_CONNECTING, State = #state{transport_pid = TransportPid}) ->
|
||||
@ -144,10 +144,11 @@ handle_event(info, {server_push_message, PacketId, <<16:8, Directive>>}, _StateN
|
||||
lager:debug("[efka_agent] get directive with packet_id: ~p, to device_uuid: ~p, content: ~p", [PacketId, Topic, Content]),
|
||||
{keep_state, State};
|
||||
|
||||
%% transport进程退出
|
||||
handle_event(info, {'EXIT', TransportPid, Reason}, _StateName, State = #state{transport_pid = TransportPid}) ->
|
||||
lager:debug("[efka_agent] transport pid: ~p, exit with reason: ~p", [TransportPid, Reason]),
|
||||
lager:warning("[efka_agent] transport pid: ~p, exit with reason: ~p", [TransportPid, Reason]),
|
||||
erlang:start_timer(5000, self(), create_transport),
|
||||
{next_status, ?STATE_DENIED, State#state{transport_pid = undefined}};
|
||||
{next_state, ?STATE_DENIED, State#state{transport_pid = undefined}};
|
||||
|
||||
handle_event(_EventType, _EventContent, _StateName, State = #state{}) ->
|
||||
NextStateName = the_next_state_name,
|
||||
|
||||
@ -49,7 +49,7 @@ response(Pid, PacketId, Response) when is_pid(Pid), is_integer(PacketId) ->
|
||||
gen_server:cast(Pid, {response, PacketId, Response}).
|
||||
|
||||
stop(Pid) when is_pid(Pid) ->
|
||||
gen_server:stop(Pid).
|
||||
gen_server:stop(Pid, normal, 2000).
|
||||
|
||||
%% @doc Spawns the server and registers the local name (unique)
|
||||
-spec(start_link(ParentPid :: pid(), Host :: string(), Port :: integer()) ->
|
||||
@ -102,7 +102,7 @@ handle_cast(connect, State = #state{host = Host, port = Port, parent_pid = Paren
|
||||
{noreply, State#state{socket = Socket}};
|
||||
{error, Reason} ->
|
||||
ParentPid ! {connect_reply, {error, Reason}},
|
||||
{noreply, Reason}
|
||||
{noreply, State#state{socket = undefined}}
|
||||
end;
|
||||
|
||||
%% auth校验
|
||||
@ -175,7 +175,7 @@ handle_info(Info, State = #state{}) ->
|
||||
%% with Reason. The return value is ignored.
|
||||
-spec(terminate(Reason :: (normal | shutdown | {shutdown, term()} | term()),
|
||||
State :: #state{}) -> term()).
|
||||
terminate(Reason, _State = #state{}) ->
|
||||
terminate(Reason, #state{}) ->
|
||||
lager:debug("[efka_transport] terminate with reason: ~p", [Reason]),
|
||||
ok.
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user