How to call an extension and get a success/fail back

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

Moderators: Lapo, Bax

bmidgley
Posts: 21
Joined: 26 Feb 2010, 04:41

How to call an extension and get a success/fail back

Postby bmidgley » 03 Mar 2010, 14:21

Hey,

We have an extension for creating a user. I call into it from a java servlet with

sfs.getZone("SOTL").getExtension("sotl_db").handleRequest("signup", params, null, 0);

where params is a java string[] with the user details. The problem is I don't see how to get a success/fail message back. Our code currently tries to send a response back to the calling user:

_server.sendResponse(response, -1, null, [$user]);

but the problem here is I passed in a null for the user so I get a null pointer exception. We can take out that response but I don't know how I'm supposed to find out if the user creation failed.

I could create a special user for this purpose but I don't see how to call the constructor since I don't know what this socket parameter is supposed to take.

Are there docs that show sending a message and getting a response? The only examples I found were calling handleInternalRequest which seems to be something entirely different and it only takes one parameter with no example showing what that parameter would be.

thanks for any pointers!
Brad
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 03 Mar 2010, 15:38

The recommended way is to use the handleInternalRequest() method as explained here: http://www.smartfoxserver.com/docs/docP ... bility.htm

The method allows a return value.
Lapo
--
gotoAndPlay()
...addicted to flash games
bmidgley
Posts: 21
Joined: 26 Feb 2010, 04:41

Postby bmidgley » 05 Mar 2010, 02:06

Lapo wrote:The recommended way is to use the handleInternalRequest() method as explained here: http://www.smartfoxserver.com/docs/docP ... bility.htm

The method allows a return value.


I saw a null pointer exception but after checking into it I found that the very most fundamental call is returning null!

sfs = SmartFoxServer.getInstance()

this is always null. Is there a configuration file I'm supposed to set up before this method will work?
bmidgley
Posts: 21
Joined: 26 Feb 2010, 04:41

Postby bmidgley » 05 Mar 2010, 04:42

bmidgley wrote:
Lapo wrote:The recommended way is to use the handleInternalRequest() method as explained here: http://www.smartfoxserver.com/docs/docP ... bility.htm

The method allows a return value.


I saw a null pointer exception but after checking into it I found that the very most fundamental call is returning null!

sfs = SmartFoxServer.getInstance()

this is always null. Is there a configuration file I'm supposed to set up before this method will work?


I should just review that I'm doing a pure java servlet deployed inside jetty. I copied jysfs.jar, json.jar, json-lib-2.1-jdk15.jar to WEB-INF/lib from the server and added these to the classpath so the build will work. I'm using SFS_PRO_1.6.6 for x86-64 and sun java 1.6.0_17-b04 under ubuntu 8.04.
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 05 Mar 2010, 08:00

I copied jysfs.jar, json.jar, json-lib-2.1-jdk15.jar to WEB-INF/lib

Don't do this, they are already in the classpath and you will obscure them.
Lapo

--

gotoAndPlay()

...addicted to flash games
bmidgley
Posts: 21
Joined: 26 Feb 2010, 04:41

Postby bmidgley » 06 Mar 2010, 03:30

Lapo wrote:
I copied jysfs.jar, json.jar, json-lib-2.1-jdk15.jar to WEB-INF/lib

Don't do this, they are already in the classpath and you will obscure them.


great, now it seems to all work. thanks for the help.
bmidgley
Posts: 21
Joined: 26 Feb 2010, 04:41

Postby bmidgley » 06 Mar 2010, 06:11

Is there a way to hot-reload a jetty servlet? I can't always restart sfs.
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 06 Mar 2010, 06:47

No need to restart SFS.
Open the AdminTool, click to the WebServer tab and stop/start the webserver only.
Side note: if you use python for servlets there's no need to do this.
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 36 guests