SmartFoxServer AJAX API(Beta) Readme
About
SmartFoxServer AJAX API is Google Web Toolkit (GWT) module that allows you to create cross-browser AJAX multi user applications using Java.
SmartFoxServer AJAX API requires the BlueBox installed and active.
NOTE: Please note the following:
-
Due to the Same Origin Policy (SOP) the SmartFoxServer AJAX API related JavaScript files and the BlueBox should be on the same domain name, protocol
and port (some browsers permit different port)
-
HTTP 1.1 requires browsers to limit the number of outgoing HTTP connections to two per domain/port.
So if you test the application loading multiple instances of the page in the same browser you may experience significant lag.
During test with Mozilla Firefox 2 and Internet Explorer 7 with three instances (the same browser instance and different tabs) of sfsChat
the lag was so big that making any test was almost impossible. The reason is the same as what makes BlueBox so fast – when HTTP request is made it
doesn’t send response until there is some update to send or given time has expired. So for example when two instances wait for response
and third tries to login it cannot because the connections limit is reached and it needs to wait until one of the other instances receive response
and this may take in some cases about 20 seconds – as you can see this is really huge lag and with more instances it gets even worse.
Starting different instances of Mozilla Firefox does not fix the problem while starting multiple instances of Internet Explorer 7 solves the problem.
Maybe the best approach is to test the application on different browsers for example Mozilla Firefox, Internet Explorer, Safari and Opera.
This approach has one big advantage – you can test how your application looks and performs on the major browsers.
Of course other solutions are also possible – for example to make the tests on different computers
Quick Start
You can found quick start guide
here
.
Usage
You can use the SmartFoxServer AJAX API in the same way as any other GWT module:
-
Add sfs_ajax_api_dir/api/sfs_ajax_api.jar to your classpath where sfs_ajax_api_dir is
the folder where you have unpacked the SmartFoxServer AJAX API
-
Your module must inherits it.gotoandplay.smartfoxserver.SFS_API module:
<inherits name="it.gotoandplay.smartfoxserver.SFS_API" />
-
To test application in hosted mode you need BlueBox running on localhost:8080.
If BlueBox is running on different host and/or port you need to make a change in the SmartFoxServer AJAX API source code.
In it.gotoandplay.smartfoxserver.server.BlueBoxProxy class change:
private static final String BLUE_BOX_URL = "http://127.0.0.1:8080/BlueBox/HttpBox.do";
with the correct address.
SmartFoxServer AJAX API and SmartFoxServer AS3 API
SmartFoxServer AJAX API is based on SmartFoxServer AS3 API so you can use the SmartFoxServer AS3 API documentation as reference.
There are some differences you should know about:
Examples
There are two examples – chat application and white board.
The chat application shows some basic SmartFoxServer functionalities as public and private messaging, room creation.
The white board application is a more complicated and shows how SFS can be used with the new <canvas> tag so
more complicated graphics features can be added. Also it demonstrates the usage of server side extensions.
How to install the examples
To install the sfsChat example just copy the content of the sfs_ajax_api_dir/examples/sfsChat/www to
sfs_install_dir/Server/webserver/webapps/root where:
-
sfs_ajax_api_dir is the folder where you have unpacked the SmartFoxServer AJAX API
-
sfs_install_dir is the folder where you have installed the SmartFoxServer
To install the whiteBoard example follow these steps (whiteBoard example uses server side extension so some additional steps are required):
-
Copy the content of the sfs_ajax_api_dir/examples/whiteBoard/www to
sfs_install_dir/Server/webserver/webapps/root where:
-
sfs_ajax_api_dir is the folder where you have unpacked the SmartFoxServer AJAX API
-
sfs_install_dir is the folder where you have installed the SmartFoxServer
-
Copy the content of the sfs_ajax_api_dir/examples/whiteBoard/sfsExtension to
sfs_install_dir/Server/sfsExtensions
-
Add the following xml snippet to the zones configuration in the SmartFoxServer configuration xml file:
<Zone name="whiteBoard" uCountUpdate="false" maxUsers="50" customLogin="false">
<Rooms>
<Room name="Lobby" maxUsers="50" isPrivate="false" isTemp="false" autoJoin="true" uCountUpdate="false">
<Extensions>
<extension name="xt" className="whiteBoardExtension.as" type="script" />
</Extensions>
</Room>
</Rooms>
</Zone>