Merge pull request #2841 from emqx/init_stats

Set stats at connection time
This commit is contained in:
tigercl 2019-09-05 14:03:51 +08:00 committed by GitHub
commit 811e85f8b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 0 deletions

View File

@ -245,6 +245,7 @@ connected(enter, _PrevSt, State = #state{chan_state = ChanState}) ->
#{client_id := ClientId} = emqx_channel:info(client, ChanState),
ok = emqx_cm:register_channel(ClientId),
ok = emqx_cm:set_chan_attrs(ClientId, attrs(State)),
ok = emqx_cm:set_chan_stats(ClientId, stats(State)),
keep_state_and_data;
connected(cast, {incoming, Packet = ?PACKET(?CONNECT)}, State) ->

View File

@ -330,6 +330,7 @@ connected(State = #state{chan_state = ChanState}) ->
#{client_id := ClientId} = emqx_channel:info(client, ChanState),
ok = emqx_cm:register_channel(ClientId),
ok = emqx_cm:set_chan_attrs(ClientId, attrs(NState)),
ok = emqx_cm:set_chan_stats(ClientId, stats(NState)),
reply(NState).
%%--------------------------------------------------------------------