sendResponse works great if ive only 1 level of array or a hash / dictionary result.
but when i've more than 1 level, action script side is not able to pick it up correctly.
using flex and smartfox 1.6.6
example:
--------------
AS script on server:
--------------
var allwinners = [];
var oWinnerInfo;
//we got a winner!
oWinner = _server.getUserById(iUserId);
oWinnerInfo = {};
oWinnerInfo.id = iUserId;
oWinnerInfo.name = oWinner.getName();
oWinnerInfo.board = aWinner[d];
allwinners.push(oWinnerInfo);
var res = {};
res._cmd = "BingoWinner";
res.winners = allwinners;
res.msg = sMsg;
_server.sendResponse(res, oRoom.getId(), null, oRoom.getAllUsers(), _server.PROTOCOL_JSON);
----------
client side (as3/flex):
var data:Object = evt.params.dataObj;
trace(data.winners[0]) // return Object
trace(data.winners[0].name) // return undefined
trace(data.winners[0]["name"]) //return undefined as well
----------------
is there anyway to get it? please note that its on json protocol...
_server.sendResponse with multi level object
debug?
where do i get the debug message?
there isnt any error on server ...
i ran the server with sh start.sh
there isnt any error on server ...
i ran the server with sh start.sh
flex..
hi,
i'm using flex sdk without flash ide
any suggestion?
i'm using flex sdk without flash ide
any suggestion?
loader + flex
Hi,
I can't run flashplayer debugger version to call on the swf directly because i'm using Loader call to get the images photo.
i will face sandbox issue with it...
Is it possible for you to duplicate the code i've mentioned above to test?
thank you
I can't run flashplayer debugger version to call on the swf directly because i'm using Loader call to get the images photo.
i will face sandbox issue with it...
Is it possible for you to duplicate the code i've mentioned above to test?
thank you
trying
Hi,
i just learned to use fdb, i'm checking on it now..
will update here...
i just learned to use fdb, i'm checking on it now..
will update here...
finally
ok, i've compiled it with debug=true...
installed flashplayer for linux based on debug more..
ran fdb
run ...
i'm seing debug messages coming through fdb, with [trace]
did some continue command several times..
and finally on finishing the game, there wasnt any error...
------------------------
[trace] XT Result: bingopicknumber
[trace] [ RECEIVED ]: {"t":"xt","b":{"r":7,"o":{"winners":[{"id":7,"board":[1,2,3,4,5]}],"_cmd":"BingoWinner","msg":"Someone Won! :"}}}, (len: 113)
[trace] XT Result: BingoWinner
------------------------
is there anything wrong with it?
installed flashplayer for linux based on debug more..
ran fdb
run ...
i'm seing debug messages coming through fdb, with [trace]
did some continue command several times..
and finally on finishing the game, there wasnt any error...
------------------------
[trace] XT Result: bingopicknumber
[trace] [ RECEIVED ]: {"t":"xt","b":{"r":7,"o":{"winners":[{"id":7,"board":[1,2,3,4,5]}],"_cmd":"BingoWinner","msg":"Someone Won! :"}}}, (len: 113)
[trace] XT Result: BingoWinner
------------------------
is there anything wrong with it?
new findings
i changed my server code to:
oWinner = _server.getUserById(iUserId);
oWinnerInfo = {};
oWinnerInfo.id = iUserId;
oWinnerInfo.id2 = iUserId;
oWinnerInfo.username = "xx" + oWinner.getName();
oWinnerInfo.username2 = oWinner.getName();
oWinnerInfo.board = aWinner[d];
allwinners.push(oWinnerInfo);
results:
[trace] [ RECEIVED ]: {"t":"xt","b":{"r":7,"o":{"winners":[{"id":0,"username":"xxtest","id2":0,"board":[1,2,3,4,5]}],"_cmd":"BingoWinner","msg":"Someone Won! :"}}}, (len: 141)
notice the username2 is missing
why?
oWinner = _server.getUserById(iUserId);
oWinnerInfo = {};
oWinnerInfo.id = iUserId;
oWinnerInfo.id2 = iUserId;
oWinnerInfo.username = "xx" + oWinner.getName();
oWinnerInfo.username2 = oWinner.getName();
oWinnerInfo.board = aWinner[d];
allwinners.push(oWinnerInfo);
results:
[trace] [ RECEIVED ]: {"t":"xt","b":{"r":7,"o":{"winners":[{"id":0,"username":"xxtest","id2":0,"board":[1,2,3,4,5]}],"_cmd":"BingoWinner","msg":"Someone Won! :"}}}, (len: 141)
notice the username2 is missing
why?
Hi there,
I am not able to reproduce the problem.
I have just substituted the data:
On the client (AS3) I get:
which looks right to me
I am not able to reproduce the problem.
I have just substituted the data:
Code: Select all
function getName()
{
return "LAPO"
}
var allwinners = []
oWinner = { "getName" : getName } //_server.getUserById(iUserId);
oWinnerInfo = {};
oWinnerInfo.id = 1 //iUserId;
oWinnerInfo.id2 = 2 // iUserId;
oWinnerInfo.username = "xx" + oWinner.getName();
oWinnerInfo.username2 = oWinner.getName();
oWinnerInfo.board = [1,2,3,4,5]
allwinners.push(oWinnerInfo);
var res = {};
res._cmd = "BingoWinner";
res.winners = allwinners;
res.msg = "This is a simple message";
_server.sendResponse(res, -1, null, [user], "json")
On the client (AS3) I get:
Code: Select all
{"t":"xt","b":{"o":{"winners":[{"username2":"LAPO","id2":2,"username":"xxLAPO","board":[1,2,3,4,5],"id":1}],"_cmd":"BingoWinner","msg":"This is a simple message"},"r":-1}}
which looks right to me
Maybe you should verify that the JSON conversion is not wrong from server side (although I wouldn't see why)
Try this code before your sendResponse call:
where resObj is your response object, the same you are passing to sendResponse.
This will output in the console the JSON data
Try this code before your sendResponse call:
Code: Select all
testJSON = __convertToJSON2(resObj)
trace(testJSON)
where resObj is your response object, the same you are passing to sendResponse.
This will output in the console the JSON data
solution
this seems to work:
oWinnerInfo.username = "" + oWinner.getName();
but thank you
oWinnerInfo.username = "" + oWinner.getName();
but thank you
Return to “Server Side Extension Development”
Who is online
Users browsing this forum: No registered users and 32 guests