Access room variable before joining it

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

Moderators: Lapo, Bax

Post Reply
tortenazor
Posts: 6
Joined: 01 Mar 2012, 12:45

Access room variable before joining it

Post by tortenazor »

Hi,

I seem not to be able to access a room's variables before joining in. I understand this is meant to minimize traffic. But I was wondering if there was any way to do it, maybe some flag I missed to have rooms broadcast variables to all the zone instead of only to joined users.

Thanks
itsmylifesoham
Posts: 186
Joined: 16 Oct 2011, 14:33

Re: Access room variable before joining it

Post by itsmylifesoham »

when you created a sfsroomvariable to be set on a room, just do

Code: Select all

 newvariable.setGlobal(true)
When a RoomVariable is set to global all changes will be broadcast not only to the Users in the Room but also to all other Users in the same Room Group .

note, users who want to see this variable from outside will have to subscribe to the room group of this room.
secret007
Posts: 58
Joined: 29 May 2009, 06:27

Re: Access room variable before joining it

Post by secret007 »

Hi,

you cannot do this on client side, you have code on server-side(Java) to achieve this,

please check the server-side java docs,
http://docs2x.smartfoxserver.com/api-do ... oc/server/
======================================================
Choose a job of your choice and you will never have to work in life !!!
htpeng
Posts: 9
Joined: 12 Mar 2012, 20:13

Re: Access room variable before joining it

Post by htpeng »

Hi,
I'm using AS3 and I have a same problem. I have to get playerlist of any rooms shown to any user who hasn't join a room. I tried to access the room playerlist, but it can't be accessed by users outside the room. So then I tried using room variables to do the list. But, it's just the same. Can't be accessed by users outside the room.

So, how do we get the list?
Or at least tell us, is there any other way to access the room variable or playerlist property without joining it?
ps. I created the rooms from client side.


Please reply :)
Regards
secret007
Posts: 58
Joined: 29 May 2009, 06:27

Re: Access room variable before joining it

Post by secret007 »

htpeng wrote:Hi,
I'm using AS3 and I have a same problem. I have to get playerlist of any rooms shown to any user who hasn't join a room. I tried to access the room playerlist, but it can't be accessed by users outside the room. So then I tried using room variables to do the list. But, it's just the same. Can't be accessed by users outside the room.

So, how do we get the list?
Or at least tell us, is there any other way to access the room variable or playerlist property without joining it?
ps. I created the rooms from client side.


Please reply :)
Regards

Hi,

again you cannot do that on client side because client cannot see outside of his room so as cannot access anything before joining the room, you have code on server side to do that, make a extension and return list of rooms or players in it and call that extension whenever you want ...
======================================================
Choose a job of your choice and you will never have to work in life !!!
htpeng
Posts: 9
Joined: 12 Mar 2012, 20:13

Re: Access room variable before joining it

Post by htpeng »

How to do it? :(
Can you give me some examples? I've never used Java before, so it's still kinda confusing. And how to get it from client side (AS3) ?


Thanks before
secret007
Posts: 58
Joined: 29 May 2009, 06:27

Re: Access room variable before joining it

Post by secret007 »

please check the java server api docs,

http://docs2x.smartfoxserver.com/api-do ... oc/server/

and if you dont know java than go on google for trainings, you will find many usefull links ..


Thanks.
======================================================
Choose a job of your choice and you will never have to work in life !!!
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Access room variable before joining it

Post by Bax »

secret007 wrote:please check the java server api docs,
http://docs2x.smartfoxserver.com/api-do ... oc/server/
In particular check the SFSApi class and the methods to create a Room or to set a Room variable.
Paolo Bax
The SmartFoxServer Team
Post Reply