Problems with Zone.getRoomListFromGroup()

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Post Reply
peter.dalton
Posts: 11
Joined: 10 Aug 2010, 21:51

Problems with Zone.getRoomListFromGroup()

Post by peter.dalton »

The method Zone.getRoomListFromGroup( string groupId ) does not seem to be working. I get an empty list however if I use the following code I find rooms:

Code: Select all

List<Room> rooms = getParentExtension().getParentZone().getRoomListFromGroup( "General" );

// rooms is empty.

List<Room> roomLists = getParentExtension().getParentZone().getRoomList();
for(Room r: roomLists)
{
    if (r.getGroupId() == "General")
    {
         // I will find my room here.
         trace( "Found room" );
    }
}
My understanding was that getRoomListFromGroup() should be doing this filtering for me.[/code]
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

Actually I think there is an error in your code.
You cannot compare Strings like this:

Code: Select all

if (r.getGroupId() == "General") 
It must be

Code: Select all

if (r.getGroupId().equals("General")) 
Once that's fixed you should get a different result.
Lapo
--
gotoAndPlay()
...addicted to flash games
peter.dalton
Posts: 11
Joined: 10 Aug 2010, 21:51

Post by peter.dalton »

Actually I found the problem seems to be that if I set the room group within CreationSFSGameSettings for the room everything works fine. However if I call room.setGroupId( "Name" ) then nothing works. My guess is that you don't expect people to call setGroupId(). I really wish that there was better documentation or that apis would not be exposed like user.setVariable() on the client if they are not supposed to be called. If the methods need to be public for your internal code I really with that you would document the issue and change the name of the function to something like setGroupIdInternal(). This would avoid a lot of confusion as I'm digging through the list of functions to determine how everything fits together.

By the way the string compares work just fine.

On a positive note I'm very excited and impressed with the changes from SFS 1.6 to 2. It is most definitely headed in the right direction.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

The problem is that the group is not modifiable at runtime.
It is decided at creation time and cannot be changed later.

As regards the documentation we ask to be patient if there's some extra method here and there. The most "beta" part of this beta is really the documentation. We are working on a lot of improvements for the docs, especially for all the articles that will come etc...

It's quite unfortunate that the javadoc tool is so limited and strictly anchored to the packaging rules of Java which are so restrained and such a pain. :(

We will have to establish a convention to mark methods that are not useful to developers.
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
Carl Lydon
Posts: 298
Joined: 12 Nov 2007, 16:15
Location: NYC

Re: Problems with Zone.getRoomListFromGroup()

Post by Carl Lydon »

This works for me:

Code: Select all

List<Room> roomList = pZone.getRoomListFromGroup(groupName);
Post Reply