Page 1 of 1

Client Side: Extension not parsing NUMBERS in returned objec

Posted: 29 Jan 2009, 21:31
by crickeys
I tried this via email (contact us), hoping the forums are faster. How do you get priority support if you purchased a license anyway?

Here's the bug I'm experiencing:

===================

I have an extension that simply sends a status variable to other users in the room with the following code:

Code: Select all

 var uID = user.getUserId();
                         
                                                
var zone = _server.getCurrentZone();                    
var roomObj = zone.getRoom(fromRoom);                                         
var usersInRoom = roomObj.getAllUsers();
                                
// send to roomObj
var response = new Object();                    
                
response.msg = "can you see this?";      
response.uID = uID;                                       
trace(uID);
response._cmd = "typs"; // typing started
                                
_server.sendResponse( response, -1, null, usersInRoom);
On the client side I get the extension response, but the object that is rebuilt has UNDEFINED as the value of uID
A simple tracing of the objects values like this:

Code: Select all

for (var i in resObj)
{
   trace("resObj."+i+" = "+resObj[i]);                                          
}
OUTPUTS:
resObj.msg = can you see this?
resObj._cmd = typs
resObj.uID = undefined

If I turn DEBUGGING ON,, I can see that the value actually gets sent by the server, but it never seems to be placed into the object. What's weird is that the STRING makes it alright, but the number doesn’t.

Here is the actual data received by the client:

[Received]: <msg t="xt"><body action="xtRes" r="-1"><dataObj><var n=&apos;uID&apos; t=&apos;n&apos;>3003</var><var n=&apos;_cmd&apos; t=&apos;s&apos;>typs</var><var n=&apos;msg&apos; t=&apos;s&apos;>can you see this?</var></dataObj></body></msg>


I'm stumped. Please help.

Posted: 30 Jan 2009, 15:57
by Lapo
I tried this via email (contact us), hoping the forums are faster. How do you get priority support if you purchased a license anyway?
We're based in Italy, your email arrived on our side at late night yesterday...
We answered this morning at 8.07 am.

Posted: 30 Jan 2009, 16:17
by crickeys
I understand the time difference, no problem there.

But, here is the "answer" I got:

that's very strange because the data is present in the debug

;<var n=&apos;uID&apos; t=&apos;n&apos;>3003</var>

is equal to:

<var n='uID' t='n'>3003</var>

Hint:
when you receive the object on the client side try looping through all data:

for (var i:String in dataObj)
trace(i + ": " + dataObj)


This really doesn't help me. I already traced the output and showed the output in my email.

Posted: 31 Jan 2009, 07:39
by Lapo
There is no known problem such as this in the AS2 Flash API. Numeric data is properly converted from and to the server.
I am trying to understand what other reasons outside the API could be the cause.

As I mentioned in my email:
in the Examples/11_pro_simpleExtension/ folder of your SmartFoxServer PRO directory you find a working example that transfers numeric values to an extension. The extension returns all numbers multiplied by two.

Since this example works out of the box I'd expect it to be working on your side too.
If this is not the case, you should backup your current extensions and config and reinstall the server because something is definitely broken.