Problem while getting other users' variables in room

Post here your questions about the Flash / Flex / Air API for SFS2X

Moderators: Lapo, Bax

Post Reply
User avatar
zubeyir
Posts: 3
Joined: 03 Feb 2014, 13:52
Location: Turkey

Problem while getting other users' variables in room

Post by zubeyir »

Hello,

I've searched forum and couldn't find the exact answer, this is why I'm posting it here.

I'm trying to get uservars of other user in the room, outside of uservar_update event. For example, when user enter room event triggered, I'm trying to get entered user's vars as below;

Code: Select all

private function onUserEnterRoom(evt:SFSEvent):void
{
evt.params.user.getVariable.....
}
Or when I enter the room, I'm trying as below;

Code: Select all

for each(var usr in sfs.lastJoinedRoom.userList){
usr.getVariable.....
}
I dont't know what is wrong, at this point I'm thinking its not possible to get other users' variables, i hope not :)

Thanks in advance
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Problem while getting other users' variables in room

Post by Lapo »

What exactly is the problem? You're trying to access the variables and you don't get what you expect?
Or are there errors? Can you be more specific.

The way you are accessing user variables is correct. As soon as you join a Room you can loop through the list of people inside that Room and read their User Variables. No problem there.

To make sure that what you are expecting is correct, you can use the AdminTool > ZoneMonitor: select the Zone and then the target Room and finally select one of the Users you are reading the variables from. From there you can see all the User's variables and double check that what you're doing in code is correct (i.e. the expected variables exist)

For more about the ZoneMonitor see here --> http://docs2x.smartfoxserver.com/Gettin ... oneMonitor

hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
zubeyir
Posts: 3
Joined: 03 Feb 2014, 13:52
Location: Turkey

Re: Problem while getting other users' variables in room

Post by zubeyir »

Hi Lapo,

Thank you for answering.

My problem is, I can read my variables but I cannot read other users' variables(they exist in same room with me) even though they have those variables which I try to get.

Let me try to explain what I'm doing;

1. I'm setting a variable to my user (and all user connected to zone)
2. User joins the room
3. Client reads user list from room as below;

Code: Select all

for each(var usr in sfs.lastJoinedRoom.userList){
     usr.getVariable("blablabla")
}
4. Here is the problem, if user is me (if usr.isMe==true) then I'am able to read variables, If it's not me, I cannot read.

Another situation;

1. My code looks like on SFSEvent.USER_ENTER_ROOM;

Code: Select all

private function onUserEnterRoom(evt:SFSEvent):void
{
    evt.params.user.getVariable.....
}
This code also cannot read variables from entered user just like above.

As you said, I already tried to check if variable really exists on server via Zone Monitor, yes they are exists but the scenario is like I said.

I don't know if I'm doing something wrong (obviously I do but I don't know what it is) because you say that I should be able to read variables of other users.

I hope I could explain my problem.
Thanks
User avatar
zubeyir
Posts: 3
Joined: 03 Feb 2014, 13:52
Location: Turkey

Re: Problem while getting other users' variables in room

Post by zubeyir »

Hello again,

I've solved my problem, its caused because of room_joined event. I was trying to read uservar before joining room.

Thanks again
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Problem while getting other users' variables in room

Post by Lapo »

Ok. That explains it :)
Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply