Page 1 of 1
Access room variable before joining it
Posted: 01 Mar 2012, 12:49
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
Re: Access room variable before joining it
Posted: 02 Mar 2012, 06:47
by itsmylifesoham
when you created a sfsroomvariable to be set on a room, just do
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.
Re: Access room variable before joining it
Posted: 17 Mar 2012, 10:12
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/
Re: Access room variable before joining it
Posted: 18 Mar 2012, 09:25
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
Re: Access room variable before joining it
Posted: 18 Mar 2012, 14:18
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 ...
Re: Access room variable before joining it
Posted: 18 Mar 2012, 15:51
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
Re: Access room variable before joining it
Posted: 18 Mar 2012, 16:01
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.
Re: Access room variable before joining it
Posted: 19 Mar 2012, 09:51
by Bax
In particular check the SFSApi class and the methods to create a Room or to set a Room variable.