fix
This commit is contained in:
parent
c2eb509706
commit
aca0dbc7d4
@ -27,6 +27,7 @@
|
|||||||
-define(STATE_DENIED, denied).
|
-define(STATE_DENIED, denied).
|
||||||
-define(STATE_CONNECTING, connecting).
|
-define(STATE_CONNECTING, connecting).
|
||||||
-define(STATE_AUTH, auth).
|
-define(STATE_AUTH, auth).
|
||||||
|
|
||||||
%% 不能推送消息到服务,但是可以接受服务器的部分指令
|
%% 不能推送消息到服务,但是可以接受服务器的部分指令
|
||||||
-define(STATE_RESTRICTED, restricted).
|
-define(STATE_RESTRICTED, restricted).
|
||||||
%% 激活状态下
|
%% 激活状态下
|
||||||
@ -117,7 +118,6 @@ handle_cast({event, ServiceId, EventType, Params}, State) ->
|
|||||||
event_type = EventType,
|
event_type = EventType,
|
||||||
params = Params
|
params = Params
|
||||||
}),
|
}),
|
||||||
|
|
||||||
safe_send(?METHOD_EVENT, EventPacket, State),
|
safe_send(?METHOD_EVENT, EventPacket, State),
|
||||||
|
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
@ -191,7 +191,9 @@ handle_info({connect_reply, Reply}, State = #state{status = ?STATE_CONNECTING, t
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
%% 收到auth回复
|
%% 收到auth回复
|
||||||
handle_info({auth_reply, {ok, ReplyBin}}, State = #state{status = ?STATE_AUTH, transport_pid = TransportPid}) when is_pid(TransportPid) ->
|
handle_info({auth_reply, Reply}, State = #state{status = ?STATE_AUTH, transport_pid = TransportPid}) when is_pid(TransportPid) ->
|
||||||
|
case Reply of
|
||||||
|
{ok, ReplyBin} ->
|
||||||
#auth_reply{code = Code, message = Message} = message_pb:decode_msg(ReplyBin, auth_reply),
|
#auth_reply{code = Code, message = Message} = message_pb:decode_msg(ReplyBin, auth_reply),
|
||||||
case Code of
|
case Code of
|
||||||
0 ->
|
0 ->
|
||||||
@ -221,11 +223,11 @@ handle_info({auth_reply, {ok, ReplyBin}}, State = #state{status = ?STATE_AUTH, t
|
|||||||
efka_transport:stop(TransportPid),
|
efka_transport:stop(TransportPid),
|
||||||
{noreply, State#state{transport_pid = undefined, status = ?STATE_DENIED}}
|
{noreply, State#state{transport_pid = undefined, status = ?STATE_DENIED}}
|
||||||
end;
|
end;
|
||||||
|
{error, Reason} ->
|
||||||
handle_info({auth_reply, {error, Reason}}, State = #state{transport_pid = TransportPid, status = ?STATE_AUTH}) ->
|
|
||||||
lager:debug("[efka_agent] auth_request failed, error: ~p", [Reason]),
|
lager:debug("[efka_agent] auth_request failed, error: ~p", [Reason]),
|
||||||
efka_transport:stop(TransportPid),
|
efka_transport:stop(TransportPid),
|
||||||
{noreply, State#state{transport_pid = undefined, status = ?STATE_DENIED}};
|
{noreply, State#state{transport_pid = undefined, status = ?STATE_DENIED}}
|
||||||
|
end;
|
||||||
|
|
||||||
%% 云端服务器推送了消息
|
%% 云端服务器推送了消息
|
||||||
%% 激活消息
|
%% 激活消息
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user