Page 1 of 1

User Variables set on the client

Posted: 20 Aug 2010, 00:52
by peter.dalton
I'm trying to create a User variable on the client using the c# interface however I never see the value get broadcasted up to the server and other clients.

Code: Select all

UserVariable var = new SFSUserVariable( "testVar", true );
m_smartFox.MySelf.SetVariable( var );
So my question is, are User and Room variables only passed around if they are set within the java server side extensions? Are all variables set on the client only stored locally? Or is there a way to set a variable from the client that is broadcasted to everyone?

If the variables are only local if set on the client I would recommend changing the API to something like: 'SetLocalVariable()' and don't have a method like 'SetVariable()' to help avoid confusion.

Thanks,

Posted: 20 Aug 2010, 06:54
by Lapo
UserVariables are not local.
If you set your variables when you are in a Room all other users in that Room will receive the update.
It's as simple as that.

Posted: 20 Aug 2010, 14:13
by peter.dalton
I guess where I'm confused is that I set the variable using the code snippet above and then use the admin tools to monitor the user. The user is definitely in the room before the variable is created however the admin tools don't show the user having any variables when I monitor him. Is the admin tool not fully functional in this aspect yet? Or is there something else that I'm missing?

When I start up SmartFox in debug mode I don't see any output in my console window related to messages being transmitted to the server when the variables are set. I would expect the variables to be sent to the server so that the server can see the state of the variables.


Thanks,

- Peter

Posted: 20 Aug 2010, 17:10
by Lapo
Oh sorry.
there's absolutely a problem in the code. Didn't notice it at first. :(
That's not the way you set variables, you always need to send a request to the server.
You must use SetUserVariablesRequest or SetRoomVariablesRequest (for RoomVars) which you find under the requests package. That's the way you use to set/change any of those variables.

The way you are doing it now you are just hacking around with the local API data.

Posted: 20 Aug 2010, 20:19
by peter.dalton
Thanks, that fixed my problem.

- Peter

Posted: 24 Aug 2010, 16:06
by tpenn
Is there any reason we would ever want to call User.SetUserVariable then?

If not and we are meant to only do that by sending a request to the server, I'd suggest that function not be exposed to us; it can only cause confusion.

Posted: 24 Aug 2010, 17:21
by Lapo
Yes, that's in fact what we'll do.
The function is exclusively used by the API internally. In the beta docs there's still a few of these private stuff that needs to be removed. Sorry about that.