Page 1 of 1

Sending response from Java extension to AS client

Posted: 14 May 2007, 04:32
by babureddy
I have the following code on AS client.

Code: Select all

smartFox.onExtensionResponse = function(resObj:Object, type:String) 
{
 _global.key = resObj.serversimulationid
 trace("ServerSimulationId from Smartfox Server = " + _global.key)
}
and the following code on java extension side

Code: Select all

	public void handleRequest(String cmd, ActionscriptObject ao, User u, int fromRoom)
	{
		if (cmd != null && cmd.equals("GETSERVERSIMULATIONID"))
		{
			String sServerSimulationId = Util.getGUID();
	    	System.out.println(" sending new server simulation id to client=" + sServerSimulationId);
		
			// All users except "who"
			LinkedList ll = new LinkedList();
			ll.add(u.getChannel());

			ActionscriptObject resObj = new ActionscriptObject();
			resObj.put("serversimulationid", sServerSimulationId);
			sendResponse(resObj, fromRoom, u, ll);

			return;
		}
}\
But I dont get any response on the client side.

Any suggestions...

Posted: 14 May 2007, 04:55
by Lapo
you didn't show the part that calls the extension from the client

TIP: use shorter names for your requests and variables, those long names will require more bandwidth

Posted: 14 May 2007, 05:05
by babureddy

Code: Select all

smartfox.sendXtMessage("g2w","GETSERVERSIMULATIONID",obj,null)

Posted: 15 May 2007, 08:57
by babureddy
Hi Lapo,

Can you please help?

Posted: 15 May 2007, 16:23
by Lapo
are you joined in a room when sending the request?

Posted: 16 May 2007, 03:42
by babureddy

Code: Select all

smartfox.autoJoin()

Posted: 16 May 2007, 09:22
by Lapo
Sorry, but I need a little more "verbose" answers or it's going to be very difficult to help.
I see you use autoJoin() but I don't know in which context :)

Let's start with checking a few things:

1. make sure you're joined in a room ( you must handle the onJoinRoom before sending any extension request )
2. make sure the extension is active (i.e. no errors are thrown when the ext is created)
3. make sure you're using the right extension name (the one specified in the config.xml)
4. activate the sfs client side debug and check if a response is coming back
5. check if you have errors in the console/log files upon sending the ext. request

Posted: 17 May 2007, 06:16
by babureddy
Java extension side shows zone, room, user and the cmd sent by the client. So I know that the user has joined the default room for the zone.

There are no errors in the java extension and console because I am able to send requests from flash to java.

How do I activate the sfs client side debug?

I need some advice on code management. Connection to smartfox server, login and autojoin code are in common.as which is common to all games. Is this ok? onConnection() onLogin and onJoinRoom() code events are not firing when placed in common.as. Where should I place these? I dont want to put them inside the flash game itself. Please suggest.