Updated to fix traffic stats
This commit is contained in:
parent
4d3acc1637
commit
aa6519209e
|
@ -24,7 +24,7 @@
|
||||||
web_menu_host/3, web_page_host/3,
|
web_menu_host/3, web_page_host/3,
|
||||||
%% Hooks
|
%% Hooks
|
||||||
register_user/2, remove_user/2, user_send_packet/1,
|
register_user/2, remove_user/2, user_send_packet/1,
|
||||||
user_send_packet_traffic/4, user_receive_packet_traffic/5,
|
user_send_packet_traffic/1, user_receive_packet_traffic/1,
|
||||||
%%user_logout_sm/3,
|
%%user_logout_sm/3,
|
||||||
user_login/1, user_logout/4]).
|
user_login/1, user_logout/4]).
|
||||||
|
|
||||||
|
@ -240,15 +240,16 @@ user_send_packet({NewEl, C2SState}) ->
|
||||||
end,
|
end,
|
||||||
{NewEl, C2SState}.
|
{NewEl, C2SState}.
|
||||||
|
|
||||||
user_send_packet_traffic(NewEl, _C2SState, FromJID, ToJID) ->
|
|
||||||
%% Only required for traffic stats
|
%% Only required for traffic stats
|
||||||
Host = FromJID#jid.lserver,
|
user_send_packet_traffic({NewEl, _C2SState} = Acc) ->
|
||||||
HostTo = ToJID#jid.lserver,
|
From = xmpp:get_from(NewEl),
|
||||||
{xmlel, Type, _, _} = NewEl,
|
To = xmpp:get_from(NewEl),
|
||||||
Type2 = case Type of
|
Host = From#jid.lserver,
|
||||||
<<"iq">> -> iq;
|
HostTo = To#jid.lserver,
|
||||||
<<"message">> -> message;
|
Type2 = case NewEl of
|
||||||
<<"presence">> -> presence
|
#iq{} -> iq;
|
||||||
|
#message{} -> message;
|
||||||
|
#presence{} -> presence
|
||||||
end,
|
end,
|
||||||
Dest = case is_host(HostTo, Host) of
|
Dest = case is_host(HostTo, Host) of
|
||||||
true -> in;
|
true -> in;
|
||||||
|
@ -256,17 +257,18 @@ user_send_packet_traffic(NewEl, _C2SState, FromJID, ToJID) ->
|
||||||
end,
|
end,
|
||||||
Table = table_name(Host),
|
Table = table_name(Host),
|
||||||
ets:update_counter(Table, {send, Host, Type2, Dest}, 1),
|
ets:update_counter(Table, {send, Host, Type2, Dest}, 1),
|
||||||
NewEl.
|
Acc.
|
||||||
|
|
||||||
%% Only required for traffic stats
|
%% Only required for traffic stats
|
||||||
user_receive_packet_traffic(FixedPacket, _C2SState, _JID, From, To) ->
|
user_receive_packet_traffic({NewEl, _C2SState} = Acc) ->
|
||||||
|
From = xmpp:get_from(NewEl),
|
||||||
|
To = xmpp:get_from(NewEl),
|
||||||
HostFrom = From#jid.lserver,
|
HostFrom = From#jid.lserver,
|
||||||
Host = To#jid.lserver,
|
Host = To#jid.lserver,
|
||||||
{xmlel, Type, _, _} = FixedPacket,
|
Type2 = case NewEl of
|
||||||
Type2 = case Type of
|
#iq{} -> iq;
|
||||||
<<"iq">> -> iq;
|
#message{} -> message;
|
||||||
<<"message">> -> message;
|
#presence{} -> presence
|
||||||
<<"presence">> -> presence
|
|
||||||
end,
|
end,
|
||||||
Dest = case is_host(HostFrom, Host) of
|
Dest = case is_host(HostFrom, Host) of
|
||||||
true -> in;
|
true -> in;
|
||||||
|
@ -274,7 +276,7 @@ user_receive_packet_traffic(FixedPacket, _C2SState, _JID, From, To) ->
|
||||||
end,
|
end,
|
||||||
Table = table_name(Host),
|
Table = table_name(Host),
|
||||||
ets:update_counter(Table, {recv, Host, Type2, Dest}, 1),
|
ets:update_counter(Table, {recv, Host, Type2, Dest}, 1),
|
||||||
FixedPacket.
|
Acc.
|
||||||
|
|
||||||
|
|
||||||
%%%==================================
|
%%%==================================
|
||||||
|
|
Loading…
Reference in New Issue