is room.getAllUsers() broken ?

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

MaHoNe
Posts: 8
Joined: 20 Oct 2018, 11:07

is room.getAllUsers() broken ?

Postby MaHoNe » 17 Apr 2019, 11:34

hello
when i use room.getAllUsers() The list comes in this way :

Code: Select all

[Lit.gotoandplay.smartfoxserver.data.User;@4caec9

The code must be :

Code: Select all

[it.gotoandplay.smartfoxserver.data.User@4caec9]

I also tried
room.getUserList()
And gave me the following :

Code: Select all

[Ljava.lang.Object;@da5a84

ps : zone.getAllUsers() works well
and i use SFS PRO 1.6.20
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: is room.getAllUsers() broken ?

Postby Lapo » 17 Apr 2019, 12:10

Hi,
Room.getAllUsers() returns an User[], in other words an array with User objects in it.

It's not clear what the problem are you having or what you're expecting instead.
Can you clarify?

Thanks.
Lapo
--
gotoAndPlay()
...addicted to flash games
MaHoNe
Posts: 8
Joined: 20 Oct 2018, 11:07

Re: is room.getAllUsers() broken ?

Postby MaHoNe » 17 Apr 2019, 13:13

room.getAllUsers() retuns that way :

Code: Select all

[Lit.gotoandplay.smartfoxserver.data.User;@4caec9

When I try :

Code: Select all

      var users = rooom.getAllUsers()   
   
        for (var i = 0; i < users.size(); i++)
        {
       // code
      // code
        } 

i get

Code: Select all

13:14:10.870 - [ WARNING ] > Error in extension [ games.as ]: Java class "[Lit.gotoandplay.smartfoxserver.data.User;" has no public instance field or method named "size". (games.as#1659) Internal: 84 -- Line number: 83 in file: games.as
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: is room.getAllUsers() broken ?

Postby Lapo » 17 Apr 2019, 13:19

The method returns a Java array, not a collection. Java arrays don't expose a method called size()
To obtain the size of the array you can check the array.length property, like in Javascript.

Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games
MaHoNe
Posts: 8
Joined: 20 Oct 2018, 11:07

Re: is room.getAllUsers() broken ?

Postby MaHoNe » 17 Apr 2019, 13:53

you are right lapo thanks

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 30 guests