chore(coap): update the subscriptions_cnt stats in time
This commit is contained in:
parent
800b154582
commit
6d2222318d
|
@ -118,8 +118,8 @@ info(ctx, #channel{ctx = Ctx}) ->
|
||||||
Ctx.
|
Ctx.
|
||||||
|
|
||||||
-spec stats(channel()) -> emqx_types:stats().
|
-spec stats(channel()) -> emqx_types:stats().
|
||||||
stats(_) ->
|
stats(#channel{session = Session}) ->
|
||||||
[].
|
emqx_coap_session:stats(Session).
|
||||||
|
|
||||||
-spec init(map(), map()) -> channel().
|
-spec init(map(), map()) -> channel().
|
||||||
init(
|
init(
|
||||||
|
@ -273,7 +273,7 @@ handle_call(
|
||||||
SubReq, TempMsg, #{}, Session
|
SubReq, TempMsg, #{}, Session
|
||||||
),
|
),
|
||||||
NSession = maps:get(session, Result),
|
NSession = maps:get(session, Result),
|
||||||
{reply, {ok, {MountedTopic, NSubOpts}}, Channel#channel{session = NSession}};
|
{reply, {ok, {MountedTopic, NSubOpts}}, [{event, updated}], Channel#channel{session = NSession}};
|
||||||
handle_call(
|
handle_call(
|
||||||
{unsubscribe, Topic},
|
{unsubscribe, Topic},
|
||||||
_From,
|
_From,
|
||||||
|
@ -300,7 +300,7 @@ handle_call(
|
||||||
UnSubReq, TempMsg, #{}, Session
|
UnSubReq, TempMsg, #{}, Session
|
||||||
),
|
),
|
||||||
NSession = maps:get(session, Result),
|
NSession = maps:get(session, Result),
|
||||||
{reply, ok, Channel#channel{session = NSession}};
|
{reply, ok, [{event, updated}], Channel#channel{session = NSession}};
|
||||||
handle_call(subscriptions, _From, Channel = #channel{session = Session}) ->
|
handle_call(subscriptions, _From, Channel = #channel{session = Session}) ->
|
||||||
Subs = emqx_coap_session:info(subscriptions, Session),
|
Subs = emqx_coap_session:info(subscriptions, Session),
|
||||||
{reply, {ok, maps:to_list(Subs)}, Channel};
|
{reply, {ok, maps:to_list(Subs)}, Channel};
|
||||||
|
|
|
@ -117,15 +117,15 @@ info(inflight, _) ->
|
||||||
info(inflight_cnt, _) ->
|
info(inflight_cnt, _) ->
|
||||||
0;
|
0;
|
||||||
info(inflight_max, _) ->
|
info(inflight_max, _) ->
|
||||||
0;
|
infinity;
|
||||||
info(retry_interval, _) ->
|
info(retry_interval, _) ->
|
||||||
infinity;
|
infinity;
|
||||||
info(mqueue, _) ->
|
info(mqueue, _) ->
|
||||||
emqx_mqueue:init(#{max_len => 0, store_qos0 => false});
|
emqx_mqueue:init(#{max_len => 0, store_qos0 => false});
|
||||||
info(mqueue_len, #session{transport_manager = TM}) ->
|
info(mqueue_len, _) ->
|
||||||
maps:size(TM);
|
|
||||||
info(mqueue_max, _) ->
|
|
||||||
0;
|
0;
|
||||||
|
info(mqueue_max, _) ->
|
||||||
|
infinity;
|
||||||
info(mqueue_dropped, _) ->
|
info(mqueue_dropped, _) ->
|
||||||
0;
|
0;
|
||||||
info(next_pkt_id, _) ->
|
info(next_pkt_id, _) ->
|
||||||
|
|
|
@ -363,6 +363,9 @@ t_clients_subscription_api(_) ->
|
||||||
maps:get(topic, SubsResp2)
|
maps:get(topic, SubsResp2)
|
||||||
),
|
),
|
||||||
|
|
||||||
|
%% check subscription_cnt
|
||||||
|
{200, #{subscriptions_cnt := 1}} = request(get, "/gateways/coap/clients/client1"),
|
||||||
|
|
||||||
{204, _} = request(delete, Path ++ "/tx"),
|
{204, _} = request(delete, Path ++ "/tx"),
|
||||||
|
|
||||||
{200, []} = request(get, Path)
|
{200, []} = request(get, Path)
|
||||||
|
|
Loading…
Reference in New Issue