Page 1 of 1
problem with setUserVariables
Posted: 26 Aug 2005, 11:18
by beate
hi lapo,
i have a little problem with smartfox.setUserVariables() in a 2-way chat application...
thats the code i use:
chat movie user 1
smartfox.onJoinRoom = function(roomObj)
{
...
var userVars = new Object();
userVars.name1 = "qwertz";
smartfox.setUserVariables(userVars);
...
}
chat movie user 2
smartfox.onUserVariablesUpdate = function(userObj)
{
...
var variables = userObj.getVariables();
var name = variables["name1"];
...
}
the problem: the variable 'name' is always 'undefined'. can you help?
thanx
beate
Posted: 26 Aug 2005, 19:26
by Lapo
the problem: the variable 'name' is always 'undefined'. can you help?
I guess you mean variable 'name1' ? ... 'name' is obviously undefined!
The rest of your code looks right...
What version of SFS are you using? Basic Pro? Which version number?
Thanks,
Posted: 26 Aug 2005, 21:25
by beate
hi lapo,
yes i mean the variable 'name1'

i use the basic 1.1.1 version
best regards
beate
Posted: 27 Aug 2005, 06:37
by Lapo
Could you please trace the version number of your client API?
Just use this code:
Code: Select all
var s = new SmartFoxClient()
trace("ver: " + s.getVersion())
Another question, what version of the API are you using? For Actionscript 1 or 2.0 ?
Thanks!

Posted: 27 Aug 2005, 10:29
by beate
hi lapo,
i use the AS 1.0 API
ver: 0.9.2
best regards
beate
Posted: 27 Aug 2005, 12:25
by Lapo
Okay, so it seems your code is right and the API versions are also the latest available.
Maybe I should see more of your code to see why you have that problem.
Did you check our "Avatar Chat" example? That example uses User Variables all over... maybe you should have a look to that source code and see how those variables are used.
Let me know if that helps

Posted: 30 Aug 2005, 15:41
by beate
hi lapo,
to find the error i used the code from the avatar example. don't work ...

the variables are 'undefined'. in the example the code works fine.
i changed the smartfoxserver config file, is that a possible reason?
best regards
beate
Posted: 30 Aug 2005, 17:39
by Lapo
beate wrote:hi lapo,
to find the error i used the code from the avatar example. don't work ...

the variables are 'undefined'. in the example the code works fine.
i changed the smartfoxserver config file, is that a possible reason?
best regards
beate
sorry, it's not clear... the avatar chat does not work for you?
Posted: 31 Aug 2005, 11:29
by beate
hi lapo,
the avatar example works. but when i use the same code in my project, on another server where sfs basic is installed, then all data stored over 'setUserVariables' are 'undefined'.
when i use the 'setRoomVariables' method to store the data then the 'onRoomVariablesUpdate' event dont fired. i found the following entry in the logfile.
2005/08/31 12:33:45.785 - [ WARNING ] [id: 15] (c.b): Unexpected Exception: java.lang.NullPointerException.
i think the error is my server not the code or sfs basic

to test this i made a little app where i write and read the variables ....
smartfox.onJoinRoom = function(roomObj)
{
var userIP = "123456";
var rVars = [];
rVars.push({name:"u_IP", value:userIP});
smartfox.setRoomVariables(rVars);
...
trace(roomObj.getVariable("u_IP"));
}
... the result is 'undefined'
thanx for support
best regards beate
Posted: 31 Aug 2005, 13:28
by Lapo
the avatar example works. but when i use the same code in my project, on another server where sfs basic is installed, then all data stored over 'setUserVariables' are 'undefined'.
I see. Then could you try to use our original avatar chat example with the "other" server ? This will tell us if the "other" server has problems or not.
Thanks

Posted: 31 Aug 2005, 17:44
by beate
hi lapo,
strangly, only with the sfs api 2.0 works the 'setUserVariables' and the 'setRoomVariables' methods without any error.
... thanks for your patience
best regards
beate
Posted: 03 Sep 2005, 13:14
by Lapo
this means that API 1.0 still are giving you problems?
Posted: 04 Sep 2005, 19:26
by beate
hi lapo,
yes, the api 2 works fine. with the api 1 i have problems (setUserVariables and setRoomVariables dont work).
best regards
beate
Posted: 05 Sep 2005, 15:03
by Lapo
beate,
I still don't get why they don't work for you. Specifically I'd like you to provide us the full code of an example that shows the problem.
I've been working with the API 1.0 for a long time and used them in the SmartChat which extensively uses UserVariables without problems.
If the code is too long or if the examples require the full FLA you sould send it to one of our emails (just click the above "Contacts" button)
thanks
