fix auth
This commit is contained in:
parent
234368b869
commit
f19faae471
@ -230,17 +230,21 @@ handle_call({publish_message, _, _, _}, _From, State) ->
|
|||||||
{reply, {error, <<"主机状态错误,发送命令失败"/utf8>>}, State};
|
{reply, {error, <<"主机状态错误,发送命令失败"/utf8>>}, State};
|
||||||
|
|
||||||
%% 关闭授权
|
%% 关闭授权
|
||||||
handle_call({activate, Auth}, _From, State = #state{uuid = UUID, host_id = HostId, has_session = false}) ->
|
handle_call({activate, Auth}, _From, State = #state{uuid = UUID, host_id = HostId, monitor_ref = MRef, channel_pid = ChannelPid, has_session = false}) ->
|
||||||
case Auth of
|
case Auth of
|
||||||
true ->
|
true ->
|
||||||
ok;
|
ok;
|
||||||
false ->
|
false ->
|
||||||
|
%% channel也是要删除的
|
||||||
|
is_reference(MRef) andalso erlang:demonitor(MRef),
|
||||||
|
is_pid(ChannelPid) andalso ws_channel:stop(ChannelPid, closed),
|
||||||
|
|
||||||
{ok, _} = host_bo:change_status(UUID, ?HOST_OFFLINE),
|
{ok, _} = host_bo:change_status(UUID, ?HOST_OFFLINE),
|
||||||
report_event(UUID, ?HOST_OFFLINE),
|
report_event(UUID, ?HOST_OFFLINE),
|
||||||
|
|
||||||
change_devices_status(HostId, ?DEVICE_UNKNOWN)
|
change_devices_status(HostId, ?DEVICE_UNKNOWN)
|
||||||
end,
|
end,
|
||||||
{reply, ok, State};
|
{reply, ok, State#state{monitor_ref = undefined, channel_pid = undefined}};
|
||||||
|
|
||||||
handle_call({activate, Auth}, _From, State = #state{host_id = HostId, uuid = UUID, monitor_ref = MRef, channel_pid = ChannelPid, has_session = true}) ->
|
handle_call({activate, Auth}, _From, State = #state{host_id = HostId, uuid = UUID, monitor_ref = MRef, channel_pid = ChannelPid, has_session = true}) ->
|
||||||
case Auth of
|
case Auth of
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user