API Example not connecting...

Post here all your questions related with beta SmartFoxServer API, such as Shockwave, Ajax ...

Moderators: Lapo, Bax

nclbbs
Posts: 6
Joined: 22 May 2008, 15:55

API Example not connecting...

Postby nclbbs » 30 Sep 2009, 16:01

Hi,

I've been having a look at the Ajax API so I downloaded it plus the google webkit plugin for eclipse and worked through the supplied video tutorial for the simpleConnect example. Unfortunately I just cannot get it working at all!

This is my first time using GWT, so I don't know whether there's something I've missed in there, but these are my issues:

1) Eclipse uses Jetty on port 8080 by default for its test hosting example, but cannot start because BlueBox has already taken this port.

2) Setting Eclipse to use any open port (e.g. 53788) gets us up and running, but then pressing 'Connect' just shows repeated 404s to '/BlueBox/HttpBox.do' since it's trying to use the same 53788 port to connect to it.

3) The '/BlueBox/HttpBox.do' value is set in HttpConnection, so I tried to set it to an absolute path with the port number included (e.g. http://127.0.0.1:8080/BlueBox/HttpBox.do) but this just means that no request appears to go out at all.

I'm not getting an exceptions thrown anywhere, it just literally sits there with the button disabled.

Any idea what obvious thing I might have missed, and how I could fix it? I'd really like to play around with this API but right now I can't even get off square 1...
patso
Posts: 380
Joined: 13 Nov 2006, 13:44
Location: Sofia, Bulgaria

Postby patso » 05 Oct 2009, 18:10

Hi,

Most likely you can connect to the BlueBox using http://127.0.0.1:8080/BlueBox/HttpBox.do because of the Same Origin Policy (http://en.wikipedia.org/wiki/Same_origin_policy). That's why the AJAX API uses servlet that runs in host mode that makes the request to the BlueBox and returns the answer returned by the BlueBox.

Now I'm not quite sure why '/BlueBox/HttpBox.do' does not work. Basically the AJAX API is developed with older version of GWT. Maybe there is some change in the newer version of GWT that makes it not working. I'll give a look this days but can't give any promises. Basically AJAX API is currently no longer developed as you can read the Lapo statement in this topic - viewtopic.php?t=5205
patso
Posts: 380
Joined: 13 Nov 2006, 13:44
Location: Sofia, Bulgaria

Postby patso » 05 Oct 2009, 19:54

Ok if you use the google plugin for eclipse then you probably have "war" directory in your project. In the web.xml file add the follow:

Code: Select all

<servlet>
  <servlet-name>blueBoxProxy</servlet-name>
  <servlet-class>it.gotoandplay.smartfoxserver.server.BlueBoxProxy</servlet-class>
</servlet>
<servlet-mapping>
  <servlet-name>blueBoxProxy</servlet-name>
  <url-pattern>/BlueBox/HttpBox.do</url-pattern>
</servlet-mapping>


Also please note that the BlueBox must run on 8080 on localhost - as far I understood you make this but just in case to remind. Of course this is not exactly mandatory but if BlueBVox does not run on localhost on 8080 then a change in the source is needed.

Also keep in mind that all this is required only for the hosted mode to work. When you deploy the application on SFS you must not add this to the web.xml(the servlet mapping).
nclbbs
Posts: 6
Joined: 22 May 2008, 15:55

Postby nclbbs » 07 Oct 2009, 09:16

Thanks, patso, I tried that mapping and it's working!

The GWT had actually already suggested putting the mapping in, but the url-pattern it inserted was '/simpleconnect/BlueBox/HttpBox.do'. As soon as I took the simpleconnect bit out it ran fine. :)

Hopefully the rest will go a little more smoothly!

Thanks again, much appreciated.
mimo2006

Postby mimo2006 » 21 Oct 2010, 06:39

Most likely you can connect to the BlueBox using http://127.0.0.1:8080/BlueBox/HttpBox.do because of the Same Origin Policy (http://en.wikipedia.org/wiki/Same_origin_policy). That's why the AJAX API uses servlet that runs in host mode that makes the request to the BlueBox and returns the answer returned by the BlueBox.

Now I'm not quite sure why '/BlueBox/HttpBox.do' does not work. Basically the AJAX API is developed with older version of GWT. Maybe there is some change in the newer version of GWT that makes it not working. I'll give a look this days but can't give any promises. Basically AJAX API is currently no longer developed as you can read the Lapo statement in this topic

http://www.games.jawaley.com
http://www.g2g2.net/

Return to “Other Client API”

Who is online

Users browsing this forum: No registered users and 3 guests