fix zd_mqtt_consumer

This commit is contained in:
anlicheng 2024-01-17 11:57:01 +08:00
parent 02bbd0832e
commit 7d26801d98

View File

@ -190,16 +190,8 @@ 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{conn_pid = ConnPid}) when is_pid(ConnPid) ->
%% topic的订阅
TopicNames = lists:map(fun({Name, _}) -> Name end, ?Topics),
{ok, _Props, _ReasonCode} = emqtt:unsubscribe(ConnPid, #{}, TopicNames),
ok = emqtt:disconnect(ConnPid),
lager:debug("[iot_zd_consumer] terminate with reason: ~p", [Reason]),
ok;
terminate(Reason, _State) ->
lager:debug("[iot_zd_consumer] terminate with reason: ~p", [Reason]),
terminate(Reason, State) ->
lager:warning("[iot_zd_consumer] terminate with reason: ~p, state: ~p", [Reason, State]),
ok.
%% @private