Sending response from Java extension to AS client

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

Post Reply
babureddy
Posts: 9
Joined: 20 Apr 2007, 08:04

Sending response from Java extension to AS client

Post 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...
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post 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
Lapo
--
gotoAndPlay()
...addicted to flash games
babureddy
Posts: 9
Joined: 20 Apr 2007, 08:04

Post by babureddy »

Code: Select all

smartfox.sendXtMessage("g2w","GETSERVERSIMULATIONID",obj,null)
babureddy
Posts: 9
Joined: 20 Apr 2007, 08:04

Post by babureddy »

Hi Lapo,

Can you please help?
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

are you joined in a room when sending the request?
Lapo
--
gotoAndPlay()
...addicted to flash games
babureddy
Posts: 9
Joined: 20 Apr 2007, 08:04

Post by babureddy »

Code: Select all

smartfox.autoJoin()
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post 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
Lapo
--
gotoAndPlay()
...addicted to flash games
babureddy
Posts: 9
Joined: 20 Apr 2007, 08:04

Post 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.
Post Reply