Page 1 of 1

private user variables

Posted: 04 Jan 2011, 07:44
by loki
I have 2 questions about UserVariables

1. I set vars to user on server side

Code: Select all

List<UserVariable> vars = new ArrayList<UserVariable>(); 
vars.add(new SFSUserVariable("money", 120));
vars.add(new SFSUserVariable("points", 3400));
smartfox.setUserVariables(user, vars);
This is working

Code: Select all

smartfox.setUserVariables(user, vars);
Not working

Code: Select all

try {

user.setVariables(vars);

}catch (SFSVariableException e) {}
Why second version not working?


2. Second question. How can I make private vars? not visible for other users only for owner, and do not throw variable_update_exception?
The only way is to use setProperty ?

Posted: 04 Jan 2011, 08:26
by smilefr
For the first part i dont know but for the second i can help:

You have to set the variable as hidden. Check the docs
setHidden

void setHidden(boolean flag)

Set the variable as "hidden". When this flag is turned on the variable will be available exclusively on the server side and it will never be transmitted to the client.

Re: private user variables

Posted: 10 Jan 2011, 07:51
by rav
loki wrote: Not working

Code: Select all

try {

user.setVariables(vars);

}catch (SFSVariableException e) {}
it works, but it just sets user variables (not fire event to user)

second:
I suppose that using property is equal using hidden variables, because user cannot change hidden variable with SetUserVariablesRequest. IMHO in any way you should use extension request to change property or hidden variable.

note: property is NOT equal hidden variable because type of property is Object and type of variable is limited by int, boolean,...array, SFSObject
and SFSArray

Posted: 13 Jan 2011, 09:01
by Lapo
You are not using the SFSApi methods, therefore you are just changing things locally. Please consult the docs here:
http://docs2x.smartfoxserver.com/Develo ... ension-api