onRoomListUpdate does not send vars!

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

Moderators: Lapo, Bax

fwe
Posts: 7
Joined: 25 Nov 2005, 23:29

onRoomListUpdate does not send vars!

Postby fwe » 26 Nov 2005, 20:26

Hello again, sorry for my massive list of topics.

Is it just me or does onRoomListUpdate does not send any variables?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 27 Nov 2005, 05:34

By default the list is not populated with variables in order to save bandwidth. If you need to receive the variables for each room you can activate it by adding:

roomListVars="true"


in your Zone definition.

Note: using many variables in many rooms could lead to a very large data transfer while receiving the room list.

hope it helps :)
Lapo
--
gotoAndPlay()
...addicted to flash games
BenSmeets
Posts: 14
Joined: 28 Mar 2006, 10:45

Postby BenSmeets » 11 May 2006, 09:11

I'm trying like crazy to get a variable from the room i am trying to connect to, but the variables are not send. I tried setting the config like you said above, but nothing helps.

What i want to do:
1. connect
2. get all rooms
3. find the first room where there is a spot open AND the room variable "GameStarted" is false

Whe i login and receive the onRoomListUpdate, i receive no RoomVariables :(
BenSmeets
Posts: 14
Joined: 28 Mar 2006, 10:45

Postby BenSmeets » 11 May 2006, 09:19

Maybe this helps:

Actionscript (summary, not in detail):

Code: Select all

m_SmartFoxClient.login(m_strZoneName, m_strUserName, null);

private function onRoomListUpdate(arrRooms) : Void
{
  // Join the first Room which is not full
  for (var room in arrRooms)
  {
    if (!arrRooms[room].getVariable("GameStarted"))
    {
        if (arrRooms[room].getMaxUsers() >= arrRooms[room].getUserCount())
        {
            m_SmartFoxClient.joinRoom(arrRooms[room].getId());
       return;
         }
     }
}


The problem is that arrRooms[room].getVariable("GameStarted") returns undefined....
User avatar
Virusescu
Posts: 260
Joined: 07 Sep 2005, 09:36
Location: [RO]Bucharest
Contact:

Postby Virusescu » 11 May 2006, 09:47

check the docs. getVariable("name") returns an object and not the actuall value
I don't have sfs here, but if I remember corectly you can retrieve the var's value like
arrRooms[room].getVariable("GameStarted").getValue();

Hope this helps
function onJoin(usr) {if (usr.getName() == "Lapo") trace ("All Hail Lapo");}
BenSmeets
Posts: 14
Joined: 28 Mar 2006, 10:45

Postby BenSmeets » 11 May 2006, 10:17

Nope, no difference. Tried logging complete objects too, the info is just not there. turning on the smartfox debugger shows the xml values are not being send. (the <vars /> tag for the room xml seems empty)
User avatar
Virusescu
Posts: 260
Joined: 07 Sep 2005, 09:36
Location: [RO]Bucharest
Contact:

Postby Virusescu » 11 May 2006, 10:20

can you see the variables if you login with the admin tool?
function onJoin(usr) {if (usr.getName() == "Lapo") trace ("All Hail Lapo");}
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 11 May 2006, 10:23

What i want to do:
1. connect
2. get all rooms
3. find the first room where there is a spot open AND the room variable "GameStarted" is false


I would probably suggest to use a server side extension to perform these tasks.
One problem you may encounter is that you find an available room but when you try to join it, it will refuse saying that the room is full.
This is because the "room-checking" operation is done on the client side, and if another similar request is done simultaneously by another client, the one with the faster conneciont will enter and the other one may not be able to do so. (if the room has only 1 "slot" free)

Back to your problem:
1- did you set the roomListVars="true" on the Zone definition?
2- are those variables that you expect specified in the <Rooms> config?
Lapo

--

gotoAndPlay()

...addicted to flash games
BenSmeets
Posts: 14
Joined: 28 Mar 2006, 10:45

Postby BenSmeets » 11 May 2006, 10:26

Virusescu wrote:can you see the variables if you login with the admin tool?


Yup, can see them there.
BenSmeets
Posts: 14
Joined: 28 Mar 2006, 10:45

Postby BenSmeets » 11 May 2006, 10:28

Lapo wrote:
What i want to do:
1. connect
2. get all rooms
3. find the first room where there is a spot open AND the room variable "GameStarted" is false


I would probably suggest to use a server side extension to perform these tasks.
One problem you may encounter is that you find an available room but when you try to join it, it will refuse saying that the room is full.
This is because the "room-checking" operation is done on the client side, and if another similar request is done simultaneously by another client, the one with the faster conneciont will enter and the other one may not be able to do so. (if the room has only 1 "slot" free)

Back to your problem:
1- did you set the roomListVars="true" on the Zone definition?
2- are those variables that you expect specified in the <Rooms> config?


Tx, yeah i am already using an extension (actionscript) for everything. I also tried setting the roomListVars="true" to every line in the config i could find (after adding it to the Zone tag had no effect) but it didn't help either.
BenSmeets
Posts: 14
Joined: 28 Mar 2006, 10:45

Postby BenSmeets » 11 May 2006, 10:29

I will try to see if i can put the "room choice" logic in the server side. Maybe that'll help with the variable issue.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 11 May 2006, 14:08

Tx, yeah i am already using an extension (actionscript) for everything. I also tried setting the roomListVars="true" to every line in the config i could find (after adding it to the Zone tag had no effect) but it didn't help either.


No, please that's not necessary. :)

NOTE: after you make that change, please restart the server (stop and then start). This will make the change effective
Lapo

--

gotoAndPlay()

...addicted to flash games
BenSmeets
Posts: 14
Joined: 28 Mar 2006, 10:45

Postby BenSmeets » 11 May 2006, 14:19

Jup, making it server side as much as i could did the trick. The problem should still exist, but this is a (better) way around it. Tnx for the help guys.

Ben
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 11 May 2006, 15:45

BenSmeets wrote:Jup, making it server side as much as i could did the trick. The problem should still exist, but this is a (better) way around it. Tnx for the help guys.

Ben


Humm... as far as I know there's no know bug with that feature.
I've done a quick test with a fresh copy of SFS 1.4 and it works without problems.
Lapo

--

gotoAndPlay()

...addicted to flash games
BenSmeets
Posts: 14
Joined: 28 Mar 2006, 10:45

Postby BenSmeets » 12 May 2006, 07:48

Hmpf, i have no idea what went wrong then. Since i am new at using smartfox, it could probably be the way i coded it. Tnx for the help.

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 53 guests