Can't send HashMap<String, Integer> to the client...
Posted: 12 Sep 2010, 13:23
Hi,
I'm currently doing a Java extension, and I'd like to send a HashMap<String, Integer>, but on client side, I only receive a null object.
The message type is XTMSG_TYPE_XML.
Server side code:
Client side code:
It works fine when I'm sending a HashMap<String, String>. Is there some restrictions on putMap? I looked in the doc but couldn't find any details about that... Or XML messages with HashMap can only handle <String, String>?...
Thanks for your help.
I'm currently doing a Java extension, and I'd like to send a HashMap<String, Integer>, but on client side, I only receive a null object.
The message type is XTMSG_TYPE_XML.
Server side code:
Code: Select all
ActionscriptObject response = new ActionscriptObject();
LinkedList ll = new LinkedList();
HashMap<String, Integer> map;
ll.add(user.getChannel());
map = new HashMap<String, Integer>();
map.put("10", 1);
map.put("20", 2);
map.put("30", 3);
response.put("_cmd", s);
response.putMap("constants", map);
this.sendResponse(response, fromRoom, null, ll);
Code: Select all
var resObj : Object = e.params.dataObj;
if (resObj._cmd != "getMoveInterpreterConstants" ||
e.params.type != SmartFoxClient.XTMSG_TYPE_XML)
{
throw new Error("[MoveInterpreter] Unhandled response (" + resObj._cmd + ", " + e.params.type + ")");
}
// resObj.constants is null.
this.fieldA = resObj.constants["10"];
this.fieldB = resObj.constants["20"];
this.fieldC = resObj.constants["30"];
Thanks for your help.