2 -- Copyright (C) 2008-2010 Matthew Wild
3 -- Copyright (C) 2008-2010 Waqas Hussain
5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information.
9 local t_insert
= table.insert
;
11 local function select_top_resources(user
)
13 local recipients
= {};
14 for _
, session
in pairs(user
.sessions
) do -- find resource with greatest priority
15 if session
.presence
then
16 local p
= session
.priority
;
19 recipients
= {session
};
20 elseif p
== priority
then
21 t_insert(recipients
, session
);
27 local function recalc_resource_map(user
)
29 user
.top_resources
= select_top_resources(user
);
30 if #user
.top_resources
== 0 then user
.top_resources
= nil; end
35 select_top_resources
= select_top_resources
;
36 recalc_resource_map
= recalc_resource_map
;