From 3b116414db5b1e11b942bb3d4bdbdcef1c2d018b Mon Sep 17 00:00:00 2001 From: Badlop Date: Fri, 31 Dec 2021 13:44:08 +0100 Subject: [PATCH] When client reconnects quickly, ensure we only request iq once --- mod_statsdx/src/mod_statsdx.erl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mod_statsdx/src/mod_statsdx.erl b/mod_statsdx/src/mod_statsdx.erl index 5b80084..52a2b2a 100644 --- a/mod_statsdx/src/mod_statsdx.erl +++ b/mod_statsdx/src/mod_statsdx.erl @@ -29,7 +29,7 @@ register_user/2, remove_user/2, user_send_packet/1, user_send_packet_traffic/1, user_receive_packet_traffic/1, %%user_logout_sm/3, - request_iqversion/3, + request_iqversion/4, user_login/1, user_logout/2]). -include("ejabberd_commands.hrl"). @@ -767,11 +767,11 @@ ms_to_time(T) -> %% Cuando un usuario conecta, pedirle iq:version a nombre de Host/mod_stats2file -user_login(#{user := User, lserver := Host, resource := Resource} = State) -> +user_login(#{user := User, lserver := Host, resource := Resource, ip := IpPort} = State) -> ets:update_counter(table_name(server), {user_login, server}, 1), ets:update_counter(table_name(Host), {user_login, Host}, 1), timer:apply_after(timer:seconds(5), ?MODULE, - request_iqversion, [User, Host, Resource]), + request_iqversion, [User, Host, Resource, IpPort]), State. @@ -806,6 +806,11 @@ user_logout(#{user := User, lserver := Host, resource := Resource} = State, _Rea end, State. +request_iqversion(User, Host, Resource, IpPort) -> + case ejabberd_sm:get_user_ip(User, Host, Resource) of + IpPort -> request_iqversion(User, Host, Resource); + _ -> ok + end. request_iqversion(User, Host, Resource) -> From = jid:make(<<"">>, Host, list_to_binary(atom_to_list(?MODULE))), To = jid:make(User, Host, Resource),