refactor(mqttsn): create subscription with any topic format
This commit is contained in:
parent
7813f402c6
commit
42e193d9be
|
@ -1782,26 +1782,12 @@ message_to_packet(
|
||||||
| {shutdown, Reason :: term(), Reply :: term(), channel()}
|
| {shutdown, Reason :: term(), Reply :: term(), channel()}
|
||||||
| {shutdown, Reason :: term(), Reply :: term(), emqx_types:packet(), channel()}.
|
| {shutdown, Reason :: term(), Reply :: term(), emqx_types:packet(), channel()}.
|
||||||
handle_call({subscribe, Topic, SubOpts}, _From, Channel) ->
|
handle_call({subscribe, Topic, SubOpts}, _From, Channel) ->
|
||||||
%% XXX: Only support short_topic_name
|
|
||||||
SubProps = maps:get(sub_props, SubOpts, #{}),
|
|
||||||
case maps:get(subtype, SubProps, short_topic_name) of
|
|
||||||
short_topic_name ->
|
|
||||||
case byte_size(Topic) of
|
|
||||||
2 ->
|
|
||||||
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({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;
|
||||||
_ ->
|
|
||||||
reply({error, bad_topic_name}, Channel)
|
|
||||||
end;
|
|
||||||
predefined_topic_id ->
|
|
||||||
reply({error, only_support_short_name_topic}, Channel);
|
|
||||||
_ ->
|
|
||||||
reply({error, only_support_short_name_topic}, Channel)
|
|
||||||
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),
|
||||||
|
|
Loading…
Reference in New Issue