fix
This commit is contained in:
parent
d412ebe692
commit
6bd2528ad5
@ -228,19 +228,28 @@ handle_call({publish_message, _, _, _}, _From, State) ->
|
||||
{reply, {error, <<"主机状态错误,发送命令失败"/utf8>>}, State};
|
||||
|
||||
%% 关闭授权
|
||||
handle_call({activate, _}, _From, State = #state{has_session = false}) ->
|
||||
handle_call({activate, Auth}, _From, State = #state{uuid = UUID, host_id = HostId, has_session = false}) ->
|
||||
case Auth of
|
||||
true ->
|
||||
ok;
|
||||
false ->
|
||||
{ok, _} = host_bo:change_status(UUID, ?HOST_OFFLINE),
|
||||
change_devices_status(HostId, ?DEVICE_UNKNOWN)
|
||||
end,
|
||||
{reply, ok, State};
|
||||
|
||||
handle_call({activate, true}, _From, State = #state{has_session = true}) ->
|
||||
{reply, ok, State};
|
||||
handle_call({activate, false}, _From, State = #state{host_id = HostId, uuid = UUID, monitor_ref = MRef, channel_pid = ChannelPid, has_session = true}) ->
|
||||
%% 取消之前的monitor
|
||||
erlang:demonitor(MRef),
|
||||
ws_channel:stop(ChannelPid, closed),
|
||||
|
||||
{ok, _} = host_bo:change_status(UUID, ?HOST_OFFLINE),
|
||||
change_devices_status(HostId, ?DEVICE_UNKNOWN),
|
||||
handle_call({activate, Auth}, _From, State = #state{host_id = HostId, uuid = UUID, monitor_ref = MRef, channel_pid = ChannelPid, has_session = true}) ->
|
||||
case Auth of
|
||||
true ->
|
||||
ok;
|
||||
false ->
|
||||
%% 取消之前的monitor
|
||||
erlang:demonitor(MRef),
|
||||
ws_channel:stop(ChannelPid, closed),
|
||||
|
||||
{ok, _} = host_bo:change_status(UUID, ?HOST_OFFLINE),
|
||||
change_devices_status(HostId, ?DEVICE_UNKNOWN)
|
||||
end,
|
||||
{reply, ok, State#state{monitor_ref = undefined, channel_pid = undefined, has_session = false}};
|
||||
|
||||
%% 绑定channel
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user