On Sun, May 5, 2013 at 5:27 PM, chrizz <
haake.c...@gmail.com> wrote:
> Hi there,
> trying to write a component which uses load_roster always returns zero.
> The code looks as following:
>
> 11 local function get_data(user)
> 12 local from,host,resource = jid_split(user.attr.from)
> 13 local roster = rm_loadroster(from,host) --rostermanager.load_roster()
> 14
> 15 module:log("info","Rosters %i", #roster)
>
> 16 return #roster
>
> 17 end
>
>
> Did I miss something? As far as I can see other modules handle load_roster
> the same way.
> And... The roster definitely is not empty and looks like this:
>
> return {
> [false] = {
> ["version"] = 6;
> };
> ["
bud...@example.com"] = {
> ["groups"] = {};
> ["subscription"] = "to";
> };
> ["
bud...@example.com"] = {
> ["groups"] = {};
> ["subscription"] = "to";
> };
> ["
bud...@example.com"] = {
> ["groups"] = {};
> ["subscription"] = "to";
> };
> }
>
>
> Any hints?
>
On line 16, remove the '#'. # basically gets you the length of an
array. The roster object is not an array, it's a map, so has zero
length.
--
Waqas Hussain