fix(mqttsn): Instantly refresh client info after subscribed/unsubscribed
This commit is contained in:
parent
bf5ee41009
commit
d77d5e33bc
|
@ -1791,14 +1791,14 @@ message_to_packet(
|
||||||
handle_call({subscribe, Topic, SubOpts}, _From, Channel) ->
|
handle_call({subscribe, Topic, SubOpts}, _From, Channel) ->
|
||||||
case do_subscribe({?SN_INVALID_TOPIC_ID, Topic, SubOpts}, Channel) of
|
case do_subscribe({?SN_INVALID_TOPIC_ID, Topic, SubOpts}, Channel) of
|
||||||
{ok, {_, NTopicName, NSubOpts}, NChannel} ->
|
{ok, {_, NTopicName, NSubOpts}, NChannel} ->
|
||||||
reply({ok, {NTopicName, NSubOpts}}, NChannel);
|
reply_and_update({ok, {NTopicName, NSubOpts}}, NChannel);
|
||||||
{error, ?SN_RC2_EXCEED_LIMITATION} ->
|
{error, ?SN_RC2_EXCEED_LIMITATION} ->
|
||||||
reply({error, exceed_limitation}, Channel)
|
reply({error, exceed_limitation}, Channel)
|
||||||
end;
|
end;
|
||||||
handle_call({unsubscribe, Topic}, _From, Channel) ->
|
handle_call({unsubscribe, Topic}, _From, Channel) ->
|
||||||
TopicFilters = [emqx_topic:parse(Topic)],
|
TopicFilters = [emqx_topic:parse(Topic)],
|
||||||
{ok, _, NChannel} = do_unsubscribe(TopicFilters, Channel),
|
{ok, _, NChannel} = do_unsubscribe(TopicFilters, Channel),
|
||||||
reply(ok, NChannel);
|
reply_and_update(ok, NChannel);
|
||||||
handle_call(subscriptions, _From, Channel = #channel{session = Session}) ->
|
handle_call(subscriptions, _From, Channel = #channel{session = Session}) ->
|
||||||
reply({ok, maps:to_list(emqx_session:info(subscriptions, Session))}, Channel);
|
reply({ok, maps:to_list(emqx_session:info(subscriptions, Session))}, Channel);
|
||||||
handle_call(kick, _From, Channel) ->
|
handle_call(kick, _From, Channel) ->
|
||||||
|
@ -2192,6 +2192,9 @@ terminate(_Reason, _Channel) ->
|
||||||
reply(Reply, Channel) ->
|
reply(Reply, Channel) ->
|
||||||
{reply, Reply, Channel}.
|
{reply, Reply, Channel}.
|
||||||
|
|
||||||
|
reply_and_update(Reply, Channel) ->
|
||||||
|
{reply, Reply, [{event, updated}], Channel}.
|
||||||
|
|
||||||
shutdown(Reason, Channel) ->
|
shutdown(Reason, Channel) ->
|
||||||
{shutdown, Reason, Channel}.
|
{shutdown, Reason, Channel}.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue