How can i access these variables when creating room

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

Moderators: Lapo, Bax

Vishwas
Posts: 81
Joined: 25 Dec 2008, 22:06

How can i access these variables when creating room

Postby Vishwas » 09 Nov 2010, 08:23

Code: Select all

var roomObj:Object = new Object()
roomObj.name = "The Cave"
roomObj.isGame = true
roomObj.maxUsers = 15

var variables:Array = new Array()
variables.push({name:"ogres", val:5, priv:true})
variables.push({name:"skeletons", val:4})

roomObj.vars = variables

smartFox.createRoom(roomObj)


How can i access the variables roomObj.vars.name and roomObj.vars.val

I get error while trying to access it at onJoinRoom() event. How else should i access it ?

Ps: I even tried to access it by roomObj.variables.val ... but i recieve errors . Strange thing is, while in debug mode, i can clearly see "variables" as one of the subobject.... but why i can't access it ?

Image
User avatar
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Postby BigFIsh » 09 Nov 2010, 20:37

Have you configured your Zone to allow viewing of room variables outside the scope of the room? i.e. <Zone roomListVars="true" ... >

Alternatively you could check the raw incoming xml messages from the server to determine if it contains the room variables. You'll need to turn on the .debug flag for your SmartFoxClient instance.
Smartfox's forum is my daily newspaper.

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 87 guests