problem with setUserVariables
problem with setUserVariables
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
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
Could you please trace the version number of your client API?
Just use this code:
Another question, what version of the API are you using? For Actionscript 1 or 2.0 ?
Thanks!

Just use this code:
Code: Select all
var s = new SmartFoxClient()
trace("ver: " + s.getVersion())Thanks!
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
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
sorry, it's not clear... the avatar chat does not work for you?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
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
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
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
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.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'.
Thanks
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
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